1
0
Fork 0
forked from len0rd/rockbox

General housekeeping: Make plugin buffer functions take size_t * instead of int * to match the parameter type of the buffer functions called in the core. Get rid of unsafe int * <==> size_t * casting. Use ssize_t where int was used and size_t where unsigned int was used in the buffer calls to not alter signedness in the plugins. No API version change since it should only be an issue for 64-bit sim builds.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13233 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-04-21 18:38:25 +00:00
parent cf6f4cf6f1
commit 26d242ae65
37 changed files with 52 additions and 51 deletions

View file

@ -63,7 +63,7 @@ void sim_codec_close(void *pd);
extern unsigned char codecbuf[];
#endif
extern void* plugin_get_audio_buffer(int *buffer_size);
extern void* plugin_get_audio_buffer(size_t *buffer_size);
struct codec_api ci_voice;

View file

@ -272,7 +272,7 @@ struct codec_api {
int (*kbd_input)(char* buffer, int buflen);
struct tm* (*get_time)(void);
int (*set_time)(const struct tm *tm);
void* (*plugin_get_audio_buffer)(int* buffer_size);
void* (*plugin_get_audio_buffer)(size_t* buffer_size);
int (*round_value_to_list32)(unsigned long value,
const unsigned long list[],
int count,

View file

@ -312,7 +312,7 @@ static void browse_cuesheet(struct cuesheet *cue)
bool display_cuesheet_content(char* filename)
{
unsigned int bufsize = 0;
size_t bufsize = 0;
struct cuesheet *cue = (struct cuesheet *)plugin_get_buffer(&bufsize);
if (!cue || bufsize < sizeof(struct cuesheet))
return false;

View file

@ -947,7 +947,7 @@ bool wps_data_load(struct wps_data *wps_data,
return false;
/* get buffer space from the plugin buffer */
unsigned int buffersize = 0;
size_t buffersize = 0;
char *wps_buffer = (char *)plugin_get_buffer(&buffersize);
if (!wps_buffer)

View file

@ -597,7 +597,8 @@ static bool clipboard_copy(void)
/* Paste a file to a new directory. Will overwrite always. */
static bool clipboard_pastefile(const char *src, const char *target, bool copy)
{
int src_fd, target_fd, buffersize, size, bytesread, byteswritten;
int src_fd, target_fd;
ssize_t buffersize, size, bytesread, byteswritten;
char *buffer;
bool result = false;

View file

@ -276,7 +276,7 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer,
char* filename, bool reload)
{
char* buffer;
int buffer_size;
ssize_t buffer_size;
bool is_playing = audio_status() & AUDIO_STATUS_PLAY;
if (!filename && !is_playing)
@ -294,7 +294,7 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer,
/* Viewing playlist on disk */
char *dir, *file, *temp_ptr;
char *index_buffer = NULL;
int index_buffer_size = 0;
ssize_t index_buffer_size = 0;
viewer->playlist = &temp_playlist;

View file

@ -667,7 +667,7 @@ int plugin_load(const char* plugin, void* parameter)
/* Returns a pointer to the portion of the plugin buffer that is not already
being used. If no plugin is loaded, returns the entire plugin buffer */
void* plugin_get_buffer(int* buffer_size)
void* plugin_get_buffer(size_t *buffer_size)
{
int buffer_pos;
@ -692,10 +692,10 @@ void* plugin_get_buffer(int* buffer_size)
Playback gets stopped, to avoid conflicts.
Talk buffer is stolen as well.
*/
void* plugin_get_audio_buffer(int* buffer_size)
void* plugin_get_audio_buffer(size_t *buffer_size)
{
#if CONFIG_CODEC == SWCODEC
return audio_get_buffer(true, (size_t *)buffer_size);
return audio_get_buffer(true, buffer_size);
#else
audio_stop();
talk_buffer_steal(); /* we use the mp3 buffer, need to tell */

View file

@ -545,8 +545,8 @@ struct plugin_api {
int (*kbd_input)(char* buffer, int buflen);
struct tm* (*get_time)(void);
int (*set_time)(const struct tm *tm);
void* (*plugin_get_buffer)(int* buffer_size);
void* (*plugin_get_audio_buffer)(int* buffer_size);
void* (*plugin_get_buffer)(size_t *buffer_size);
void* (*plugin_get_audio_buffer)(size_t *buffer_size);
void (*plugin_tsr)(bool (*exit_callback)(bool reenter));
#ifdef IRAM_STEAL
void (*plugin_iram_init)(char *iramstart, char *iramcopy, size_t iram_size,
@ -653,8 +653,8 @@ extern unsigned char plugin_end_addr[];
#endif /* PLUGIN */
int plugin_load(const char* plugin, void* parameter);
void* plugin_get_buffer(int *buffer_size);
void* plugin_get_audio_buffer(int *buffer_size);
void* plugin_get_buffer(size_t *buffer_size);
void* plugin_get_audio_buffer(size_t *buffer_size);
#ifdef IRAM_STEAL
void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
char *iedata, size_t iedata_size);

View file

@ -1143,7 +1143,7 @@ int main(void* parameter)
#ifdef DEBUG
int button;
#endif
int stacksize;
ssize_t stacksize;
void* stack;
mbus_init(); /* init the M-Bus layer */

View file

@ -552,7 +552,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int t_disp = 0;
#ifdef USE_GSLIB
unsigned char *gbuf;
unsigned int gbuf_size = 0;
size_t gbuf_size = 0;
bool mode_switch = true;
#endif

View file

@ -62,10 +62,10 @@ void init_screen(void)
/* global vars for pl_malloc() */
void *bufptr;
int bufleft;
ssize_t bufleft;
/* simple function to "allocate" memory in pluginbuffer. */
void *pl_malloc(int size)
void *pl_malloc(ssize_t size)
{
void *ptr;
ptr = bufptr;

View file

@ -231,7 +231,7 @@ void Z_Close(void)
void Z_Init(void)
{
unsigned int size;
size_t size;
#ifdef INSTRUMENTED
if (!(HEADER_SIZE >= sizeof(memblock_t) && MIN_RAM > LEAVE_ASIDE))
I_Error("Z_Init: Sanity check failed");

View file

@ -37,7 +37,7 @@ static unsigned char cooling_map[LCD_HEIGHT][LCD_WIDTH];
#ifndef HAVE_LCD_COLOR
static unsigned char *gbuf;
static unsigned int gbuf_size = 0;
static size_t gbuf_size = 0;
static unsigned char draw_buffer[8*LCD_WIDTH];
#endif

View file

@ -880,7 +880,7 @@ void DoUserDialog(char* filename)
char default_filename[32];
int button;
int rc; /* generic return code */
int memleft;
ssize_t memleft;
tCheckROM result;
bool is_romless;

View file

@ -75,7 +75,7 @@ PLUGIN_HEADER
static struct plugin_api* rb; /* global api struct pointer */
static char pbuf[32]; /* global printf buffer */
static unsigned char *gbuf;
static unsigned int gbuf_size = 0;
static size_t gbuf_size = 0;
/**************************** main function ********************************/

View file

@ -25,7 +25,7 @@
#ifndef SIMULATOR /* only for target */
unsigned char *audiobuf;
int audiobuf_size;
ssize_t audiobuf_size;
#if defined(IRIVER_H120)
#define PLATFORM_ID ID_IRIVER_H100

View file

@ -27,7 +27,7 @@ PLUGIN_HEADER
static struct plugin_api* rb;
int buf_size;
ssize_t buf_size;
static char *filename;
static int readsize;
static char *stringbuffer;

View file

@ -1874,7 +1874,7 @@ unsigned char* buf; /* up to here currently used by image(s) */
/* the remaining free part of the buffer for compressed+uncompressed images */
unsigned char* buf_images;
int buf_size, buf_images_size;
ssize_t buf_size, buf_images_size;
/* the root of the images, hereafter are decompresed ones */
unsigned char* buf_root;
int root_size;

View file

@ -47,7 +47,7 @@ enum plugin_status run_overlay(struct plugin_api* rb, void* parameter,
unsigned char *filename, unsigned char *name)
{
int fd, readsize;
int audiobuf_size;
ssize_t audiobuf_size;
unsigned char *audiobuf;
static struct plugin_header header;

View file

@ -179,7 +179,7 @@ static unsigned max_iter;
#ifdef USEGSLIB
static unsigned char *gbuf;
static unsigned int gbuf_size = 0;
static size_t gbuf_size = 0;
static unsigned char imgbuffer[LCD_HEIGHT];
#else
static fb_data imgbuffer[LCD_HEIGHT];

View file

@ -146,7 +146,7 @@ int midimain(void * filename);
void *alloc(int size)
{
static char *offset = NULL;
static int totalSize = 0;
static ssize_t totalSize = 0;
char *ret;
int remainder = size % 4;
@ -186,7 +186,7 @@ void *alloc(int size)
void *alloc(int size)
{
static char *offset = NULL;
static int totalSize = 0;
static ssize_t totalSize = 0;
char *ret;

View file

@ -1607,7 +1607,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int status = PLUGIN_ERROR; /* assume failure */
void* audiobuf;
int audiosize;
ssize_t audiosize;
int in_file;
uint8_t* buffer;
size_t file_remaining;
@ -1652,7 +1652,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
buffer_size = audiosize - (PCMBUFFER_SIZE+PCMBUFFER_GUARD_SIZE+
MPABUF_SIZE+LIBMPEG2BUFFER_SIZE);
DEBUGF("audiosize=%d, buffer_size=%ld\n",audiosize,buffer_size);
DEBUGF("audiosize=%ld, buffer_size=%ld\n",audiosize,buffer_size);
buffer = mpeg2_malloc(buffer_size,-1);
if (buffer == NULL)

View file

@ -45,7 +45,7 @@ static int redphase = 0, greenphase = 50, bluephase = 100;
static unsigned char colours[256]; /* Smooth transition of shades */
static unsigned char graybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */
static unsigned char *gbuf;
static unsigned int gbuf_size = 0;
static size_t gbuf_size = 0;
#endif
static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */
static int plasma_frequency;

View file

@ -27,7 +27,7 @@ static int dirs_count;
static int lasttick;
#define RFA_FILE ROCKBOX_DIR "/folder_advance_list.dat"
char *buffer = NULL;
int buffer_size;
ssize_t buffer_size;
struct file_format {
int count;
char folder[][MAX_PATH];

View file

@ -645,7 +645,7 @@ void DoUserDialog(char* filename)
int rc; /* generic return code */
UINT32 space, aligned_size, true_size;
UINT8* pos;
int memleft;
ssize_t memleft;
UINT32 crc;
bool show_greet = false;
@ -849,7 +849,7 @@ void DoUserDialog(char* filename)
int rc; /* generic return code */
UINT32 space, aligned_size, true_size;
UINT8* pos;
int memleft;
ssize_t memleft;
UINT32 crc;
/* this can only work if Rockbox runs in DRAM, not flash ROM */

View file

@ -44,7 +44,7 @@ struct options options;
void *audio_bufferbase;
void *audio_bufferpointer;
unsigned int audio_buffer_free;
size_t audio_buffer_free;
void *my_malloc(size_t size)
{
@ -194,13 +194,13 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
if(rb->audio_status())
{
audio_bufferbase = audio_bufferpointer
= rb->plugin_get_buffer((int *)&audio_buffer_free);
= rb->plugin_get_buffer(&audio_buffer_free);
plugbuf=true;
}
else
{
audio_bufferbase = audio_bufferpointer
= rb->plugin_get_audio_buffer((int *)&audio_buffer_free);
= rb->plugin_get_audio_buffer(&audio_buffer_free);
plugbuf=false;
}
#if MEM <= 8 && !defined(SIMULATOR)

View file

@ -25,7 +25,7 @@ PLUGIN_HEADER
void *audio_bufferbase;
void *audio_bufferpointer;
unsigned int audio_buffer_free;
size_t audio_buffer_free;
struct plugin_api* rb;
int w, h, y;

View file

@ -327,7 +327,7 @@ int load_all_levels(void)
{
int linecnt = 0;
int fd;
int size;
ssize_t size;
char buf[64]; /* Larger than WIDTH, to allow for whitespace after the
lines */

View file

@ -59,7 +59,7 @@ PLUGIN_HEADER
static struct plugin_api* rb;
int buf_size;
ssize_t buf_size;
static char *filename;
static int num_entries;
static char **pointers;

View file

@ -573,7 +573,7 @@ static int copy_file(
unsigned char *buffer;
unsigned int i = 0;
ssize_t bytes_read = 1; /* ensure the for loop is executed */
unsigned int buffer_size;
size_t buffer_size;
buffer = rb->plugin_get_buffer(&buffer_size);
for (i = 0; i < bytes && bytes_read > 0; i += bytes_read)

View file

@ -32,7 +32,7 @@ PLUGIN_HEADER
static struct plugin_api* rb;
static unsigned char* audiobuf;
static int audiobufsize;
static ssize_t audiobufsize;
static unsigned short frnd_buffer;
static int line = 0;

View file

@ -23,7 +23,7 @@ PLUGIN_HEADER
static struct plugin_api* rb;
static char *audiobuf;
static int audiobuflen;
static ssize_t audiobuflen;
static void xingupdate(int percent)
{

View file

@ -38,7 +38,7 @@ void *memcpy(void *dest, const void *src, size_t n) {
}
static char *audiobuf;
static int audiobuflen;
static ssize_t audiobuflen;
static struct wav_header {
char ckID [4]; /* RIFF chuck header */

View file

@ -3138,7 +3138,7 @@ void dma_end_isr(void) __attribute__((interrupt_handler));
static struct plugin_api *rb;
static unsigned char *aud_buf;
static int aud_size;
static ssize_t aud_size;
static unsigned char *plug_buf;
static void (*pcm_callback)(unsigned char**, int*) = NULL;
@ -3649,7 +3649,7 @@ int play_file(char* filename)
/* plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int buf_size;
ssize_t buf_size;
rb = api;

View file

@ -60,7 +60,7 @@ struct peakstruct
/* global vars */
static char *audiobuf;
static int audiobuflen;
static ssize_t audiobuflen;
static uint32_t mempeakcount = 0;
static uint32_t filepeakcount = 0;
static uint32_t fppmp = 0; /* file peaks per mem peaks */

View file

@ -19,7 +19,7 @@ int my_putc(char c , int fd){
void *my_malloc(size_t size)
{
static char *offset = NULL;
static int totalSize = 0;
static ssize_t totalSize = 0;
char *ret;
int remainder = size % 4;

View file

@ -52,7 +52,7 @@ static int previous_state;
#ifdef USE_GRAY
static unsigned char *gbuf;
static unsigned int gbuf_size = 0;
static size_t gbuf_size = 0;
#endif
long video_frames IBSS_ATTR = 0 ;