1
0
Fork 0
forked from len0rd/rockbox

Fix size_t handling in plugin_get_buffer()

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25884 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2010-05-07 19:27:42 +00:00
parent 6027b91603
commit 8d4ff638b9
14 changed files with 42 additions and 36 deletions

View file

@ -1141,6 +1141,7 @@ int main(const void* parameter)
#ifdef DEBUG
int button;
#endif
size_t buf_size;
ssize_t stacksize;
void* stack;
@ -1155,7 +1156,8 @@ int main(const void* parameter)
#endif
/* init the worker thread */
stack = rb->plugin_get_buffer((size_t *)&stacksize); /* use the rest as stack */
stack = rb->plugin_get_buffer(&buf_size); /* use the rest as stack */
stacksize = buf_size;
stack = (void*)(((unsigned int)stack + 100) & ~3); /* a bit away, 32 bit align */
stacksize = (stacksize - 100) & ~3;
if (stacksize < DEFAULT_STACK_SIZE)

View file

@ -32,12 +32,12 @@ short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}};
/* global vars for pl_malloc() */
void *bufptr = NULL;
ssize_t bufleft;
size_t bufleft;
/* simple function to "allocate" memory in pluginbuffer.
* (borrowed from dict.c)
*/
void *pl_malloc(ssize_t size)
void *pl_malloc(size_t size)
{
void *ptr;
ptr = bufptr;
@ -57,7 +57,7 @@ void *pl_malloc(ssize_t size)
/* init function for pl_malloc() */
void pl_malloc_init(void)
{
bufptr = rb->plugin_get_buffer((size_t *)&bufleft);
bufptr = rb->plugin_get_buffer(&bufleft);
}
void process_tag(struct pgn_game_node* game, char* buffer){

View file

@ -62,10 +62,10 @@ void init_screen(void)
/* global vars for pl_malloc() */
void *bufptr;
ssize_t bufleft;
size_t bufleft;
/* simple function to "allocate" memory in pluginbuffer. */
void *pl_malloc(ssize_t size)
void *pl_malloc(size_t size)
{
void *ptr;
ptr = bufptr;
@ -85,7 +85,7 @@ void *pl_malloc(ssize_t size)
/* init function for pl_malloc() */
void pl_malloc_init(void)
{
bufptr = rb->plugin_get_buffer((size_t *)&bufleft);
bufptr = rb->plugin_get_buffer(&bufleft);
}
/* for endian problems */

View file

@ -597,7 +597,7 @@ void DoUserDialog(char* filename)
char default_filename[32];
int button;
int rc; /* generic return code */
ssize_t memleft;
size_t memleft;
tCheckROM result;
bool is_romless;
@ -644,7 +644,7 @@ void DoUserDialog(char* filename)
}
/* "allocate" memory */
sector = rb->plugin_get_buffer((size_t *)&memleft);
sector = rb->plugin_get_buffer(&memleft);
if (memleft < SEC_SIZE) /* need buffer for a flash sector */
{
rb->splash(HZ*3, "Out of memory");
@ -837,7 +837,7 @@ void DoUserDialog(char* filename)
char default_filename[32];
int button;
int rc; /* generic return code */
ssize_t memleft;
size_t memleft;
tCheckROM result;
bool is_romless;
@ -884,7 +884,7 @@ void DoUserDialog(char* filename)
}
/* "allocate" memory */
sector = rb->plugin_get_buffer((size_t *)&memleft);
sector = rb->plugin_get_buffer(&memleft);
if (memleft < SEC_SIZE) /* need buffer for a flash sector */
{
rb->splash(HZ*3, "Out of memory");

View file

@ -49,7 +49,7 @@ enum plugin_status run_overlay(const void* parameter,
unsigned char *filename, unsigned char *name)
{
int fd, readsize;
ssize_t audiobuf_size;
size_t audiobuf_size;
unsigned char *audiobuf;
static struct plugin_header header;
@ -80,7 +80,7 @@ enum plugin_status run_overlay(const void* parameter,
return PLUGIN_ERROR;
}
audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuf_size);
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
if (header.load_addr < audiobuf ||
header.end_addr > audiobuf + audiobuf_size)
{

View file

@ -33,7 +33,7 @@ static int lasttick;
#define MAX_REMOVED_DIRS 10
char *buffer = NULL;
ssize_t buffer_size;
size_t buffer_size;
int num_replaced_dirs = 0;
char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH];
struct file_format {
@ -248,7 +248,7 @@ int load_list(void)
int myfd = rb->open(RFA_FILE,O_RDONLY);
if (myfd < 0)
return -1;
buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size);
buffer = rb->plugin_get_audio_buffer(&buffer_size);
if (!buffer)
{
return -2;
@ -414,7 +414,7 @@ int import_list_from_file_text(void)
{
char line[MAX_PATH];
buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size);
buffer = rb->plugin_get_audio_buffer(&buffer_size);
if (buffer == NULL)
{
rb->splash(HZ*2, "failed to get audio buffer");

View file

@ -568,7 +568,7 @@ static void DoUserDialog(char* filename)
int rc; /* generic return code */
UINT32 space, aligned_size, true_size;
UINT8* pos;
ssize_t memleft;
size_t memleft;
unsigned bl_version;
bool show_greet = false;
@ -587,7 +587,7 @@ static void DoUserDialog(char* filename)
}
/* "allocate" memory */
sector = rb->plugin_get_buffer((size_t *)&memleft);
sector = rb->plugin_get_buffer(&memleft);
if (memleft < SECTORSIZE) /* need buffer for a flash sector */
{
rb->splash(HZ*3, "Out of memory");
@ -772,7 +772,7 @@ static void DoUserDialog(char* filename)
int rc; /* generic return code */
UINT32 space, aligned_size, true_size;
UINT8* pos;
ssize_t memleft;
size_t memleft;
unsigned bl_version;
/* this can only work if Rockbox runs in DRAM, not flash ROM */
@ -790,7 +790,7 @@ static void DoUserDialog(char* filename)
}
/* "allocate" memory */
sector = rb->plugin_get_buffer((size_t *)&memleft);
sector = rb->plugin_get_buffer(&memleft);
if (memleft < SECTORSIZE) /* need buffer for a flash sector */
{
rb->splash(HZ*3, "Out of memory");

View file

@ -409,13 +409,13 @@ int load_all_levels(void)
{
int linecnt = 0;
int fd;
ssize_t size;
size_t size;
char buf[64]; /* Larger than WIDTH, to allow for whitespace after the
lines */
/* Init the level_cache pointer and
calculate how many levels that will fit */
level_cache = rb->plugin_get_buffer((size_t *)&size);
level_cache = rb->plugin_get_buffer(&size);
max_levels = size / (HEIGHT*WIDTH);
num_levels = 0;

View file

@ -59,7 +59,7 @@
PLUGIN_HEADER
ssize_t buf_size;
size_t buf_size;
static char *filename;
static int num_entries;
static char **pointers;
@ -104,7 +104,7 @@ int read_buffer(int offset)
return readsize * 10 - 2;
/* Temporary fix until we can do merged sorting */
if(readsize == buf_size)
if(readsize == (int)buf_size)
return buf_size; /* File too big */
buf_ptr = stringbuffer;
@ -192,7 +192,7 @@ enum plugin_status plugin_start(const void* parameter)
filename = (char *)parameter;
buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */
buf = rb->plugin_get_audio_buffer(&buf_size); /* start munching memory */
stringbuffer = buf;
pointers = (char **)(buf + buf_size - sizeof(int));

View file

@ -23,7 +23,7 @@
PLUGIN_HEADER
static char *audiobuf;
static ssize_t audiobuflen;
static size_t audiobuflen;
unsigned char xingbuf[1500];
char tmpname[MAX_PATH];
@ -267,7 +267,7 @@ enum plugin_status plugin_start(const void *parameter)
if (!parameter)
return PLUGIN_ERROR;
audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen);
audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);

View file

@ -3059,11 +3059,13 @@ enum plugin_status plugin_start(const void* file)
int lastbutton = BUTTON_NONE;
bool autoscroll = false;
long old_tick;
size_t buf_size;
old_tick = *rb->current_tick;
/* get the plugin buffer */
buffer = rb->plugin_get_buffer((size_t *)&buffer_size);
buffer = rb->plugin_get_buffer(&buf_size);
buffer_size = buf_size;
if (buffer_size == 0)
{
rb->splash(HZ, "buffer does not allocate !!");

View file

@ -3649,7 +3649,7 @@ int play_file(char* filename)
/* plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
ssize_t buf_size;
size_t buf_size;
if (!parameter)
{
@ -3657,14 +3657,15 @@ enum plugin_status plugin_start(const void* parameter)
return PLUGIN_OK;
}
plug_buf = rb->plugin_get_buffer((size_t *)&buf_size);
plug_buf = rb->plugin_get_buffer(&buf_size);
if (buf_size < 6700) /* needed for i2c transfer */
{
rb->splash(HZ, "Out of memory.");
return PLUGIN_ERROR;
}
aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size);
aud_buf = rb->plugin_get_audio_buffer(&buf_size);
aud_size = buf_size;
switch (play_file((char*)parameter))
{

View file

@ -3750,14 +3750,14 @@ static int recording_menu(void)
/* plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
ssize_t buf_size;
size_t buf_size;
int align;
int rc;
const char *recbasedir;
(void)parameter;
plug_buf = rb->plugin_get_buffer((size_t *)&buf_size);
plug_buf = rb->plugin_get_buffer(&buf_size);
if (buf_size < 6700) /* needed for i2c transfer */
{
rb->splash(HZ, "Out of memory.");
@ -3776,7 +3776,8 @@ enum plugin_status plugin_start(const void* parameter)
}
}
aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size);
aud_buf = rb->plugin_get_audio_buffer(&buf_size);
aud_size = buf_size;
align = (-(long)aud_buf) & 3;
aud_buf += align;
aud_size -= align;

View file

@ -60,7 +60,7 @@ struct peakstruct
/* global vars */
static char *audiobuf;
static ssize_t audiobuflen;
static size_t audiobuflen;
static uint32_t mempeakcount = 0;
static uint32_t filepeakcount = 0;
static uint32_t fppmp = 0; /* file peaks per mem peaks */
@ -362,7 +362,7 @@ enum plugin_status plugin_start(const void *parameter)
if (!parameter)
return PLUGIN_ERROR;
audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen);
audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
if (!audiobuf)
{