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:
parent
6027b91603
commit
8d4ff638b9
14 changed files with 42 additions and 36 deletions
|
@ -1141,6 +1141,7 @@ int main(const void* parameter)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int button;
|
int button;
|
||||||
#endif
|
#endif
|
||||||
|
size_t buf_size;
|
||||||
ssize_t stacksize;
|
ssize_t stacksize;
|
||||||
void* stack;
|
void* stack;
|
||||||
|
|
||||||
|
@ -1155,7 +1156,8 @@ int main(const void* parameter)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* init the worker thread */
|
/* 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 */
|
stack = (void*)(((unsigned int)stack + 100) & ~3); /* a bit away, 32 bit align */
|
||||||
stacksize = (stacksize - 100) & ~3;
|
stacksize = (stacksize - 100) & ~3;
|
||||||
if (stacksize < DEFAULT_STACK_SIZE)
|
if (stacksize < DEFAULT_STACK_SIZE)
|
||||||
|
|
|
@ -32,12 +32,12 @@ short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}};
|
||||||
|
|
||||||
/* global vars for pl_malloc() */
|
/* global vars for pl_malloc() */
|
||||||
void *bufptr = NULL;
|
void *bufptr = NULL;
|
||||||
ssize_t bufleft;
|
size_t bufleft;
|
||||||
|
|
||||||
/* simple function to "allocate" memory in pluginbuffer.
|
/* simple function to "allocate" memory in pluginbuffer.
|
||||||
* (borrowed from dict.c)
|
* (borrowed from dict.c)
|
||||||
*/
|
*/
|
||||||
void *pl_malloc(ssize_t size)
|
void *pl_malloc(size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ptr = bufptr;
|
ptr = bufptr;
|
||||||
|
@ -57,7 +57,7 @@ void *pl_malloc(ssize_t size)
|
||||||
/* init function for pl_malloc() */
|
/* init function for pl_malloc() */
|
||||||
void pl_malloc_init(void)
|
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){
|
void process_tag(struct pgn_game_node* game, char* buffer){
|
||||||
|
|
|
@ -62,10 +62,10 @@ void init_screen(void)
|
||||||
|
|
||||||
/* global vars for pl_malloc() */
|
/* global vars for pl_malloc() */
|
||||||
void *bufptr;
|
void *bufptr;
|
||||||
ssize_t bufleft;
|
size_t bufleft;
|
||||||
|
|
||||||
/* simple function to "allocate" memory in pluginbuffer. */
|
/* simple function to "allocate" memory in pluginbuffer. */
|
||||||
void *pl_malloc(ssize_t size)
|
void *pl_malloc(size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ptr = bufptr;
|
ptr = bufptr;
|
||||||
|
@ -85,7 +85,7 @@ void *pl_malloc(ssize_t size)
|
||||||
/* init function for pl_malloc() */
|
/* init function for pl_malloc() */
|
||||||
void pl_malloc_init(void)
|
void pl_malloc_init(void)
|
||||||
{
|
{
|
||||||
bufptr = rb->plugin_get_buffer((size_t *)&bufleft);
|
bufptr = rb->plugin_get_buffer(&bufleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for endian problems */
|
/* for endian problems */
|
||||||
|
|
|
@ -597,7 +597,7 @@ void DoUserDialog(char* filename)
|
||||||
char default_filename[32];
|
char default_filename[32];
|
||||||
int button;
|
int button;
|
||||||
int rc; /* generic return code */
|
int rc; /* generic return code */
|
||||||
ssize_t memleft;
|
size_t memleft;
|
||||||
tCheckROM result;
|
tCheckROM result;
|
||||||
bool is_romless;
|
bool is_romless;
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ void DoUserDialog(char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "allocate" memory */
|
/* "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 */
|
if (memleft < SEC_SIZE) /* need buffer for a flash sector */
|
||||||
{
|
{
|
||||||
rb->splash(HZ*3, "Out of memory");
|
rb->splash(HZ*3, "Out of memory");
|
||||||
|
@ -837,7 +837,7 @@ void DoUserDialog(char* filename)
|
||||||
char default_filename[32];
|
char default_filename[32];
|
||||||
int button;
|
int button;
|
||||||
int rc; /* generic return code */
|
int rc; /* generic return code */
|
||||||
ssize_t memleft;
|
size_t memleft;
|
||||||
tCheckROM result;
|
tCheckROM result;
|
||||||
bool is_romless;
|
bool is_romless;
|
||||||
|
|
||||||
|
@ -884,7 +884,7 @@ void DoUserDialog(char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "allocate" memory */
|
/* "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 */
|
if (memleft < SEC_SIZE) /* need buffer for a flash sector */
|
||||||
{
|
{
|
||||||
rb->splash(HZ*3, "Out of memory");
|
rb->splash(HZ*3, "Out of memory");
|
||||||
|
|
|
@ -49,7 +49,7 @@ enum plugin_status run_overlay(const void* parameter,
|
||||||
unsigned char *filename, unsigned char *name)
|
unsigned char *filename, unsigned char *name)
|
||||||
{
|
{
|
||||||
int fd, readsize;
|
int fd, readsize;
|
||||||
ssize_t audiobuf_size;
|
size_t audiobuf_size;
|
||||||
unsigned char *audiobuf;
|
unsigned char *audiobuf;
|
||||||
static struct plugin_header header;
|
static struct plugin_header header;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ enum plugin_status run_overlay(const void* parameter,
|
||||||
return PLUGIN_ERROR;
|
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 ||
|
if (header.load_addr < audiobuf ||
|
||||||
header.end_addr > audiobuf + audiobuf_size)
|
header.end_addr > audiobuf + audiobuf_size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ static int lasttick;
|
||||||
#define MAX_REMOVED_DIRS 10
|
#define MAX_REMOVED_DIRS 10
|
||||||
|
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
ssize_t buffer_size;
|
size_t buffer_size;
|
||||||
int num_replaced_dirs = 0;
|
int num_replaced_dirs = 0;
|
||||||
char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH];
|
char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH];
|
||||||
struct file_format {
|
struct file_format {
|
||||||
|
@ -248,7 +248,7 @@ int load_list(void)
|
||||||
int myfd = rb->open(RFA_FILE,O_RDONLY);
|
int myfd = rb->open(RFA_FILE,O_RDONLY);
|
||||||
if (myfd < 0)
|
if (myfd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size);
|
buffer = rb->plugin_get_audio_buffer(&buffer_size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
|
@ -414,7 +414,7 @@ int import_list_from_file_text(void)
|
||||||
{
|
{
|
||||||
char line[MAX_PATH];
|
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)
|
if (buffer == NULL)
|
||||||
{
|
{
|
||||||
rb->splash(HZ*2, "failed to get audio buffer");
|
rb->splash(HZ*2, "failed to get audio buffer");
|
||||||
|
|
|
@ -568,7 +568,7 @@ static void DoUserDialog(char* filename)
|
||||||
int rc; /* generic return code */
|
int rc; /* generic return code */
|
||||||
UINT32 space, aligned_size, true_size;
|
UINT32 space, aligned_size, true_size;
|
||||||
UINT8* pos;
|
UINT8* pos;
|
||||||
ssize_t memleft;
|
size_t memleft;
|
||||||
unsigned bl_version;
|
unsigned bl_version;
|
||||||
bool show_greet = false;
|
bool show_greet = false;
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ static void DoUserDialog(char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "allocate" memory */
|
/* "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 */
|
if (memleft < SECTORSIZE) /* need buffer for a flash sector */
|
||||||
{
|
{
|
||||||
rb->splash(HZ*3, "Out of memory");
|
rb->splash(HZ*3, "Out of memory");
|
||||||
|
@ -772,7 +772,7 @@ static void DoUserDialog(char* filename)
|
||||||
int rc; /* generic return code */
|
int rc; /* generic return code */
|
||||||
UINT32 space, aligned_size, true_size;
|
UINT32 space, aligned_size, true_size;
|
||||||
UINT8* pos;
|
UINT8* pos;
|
||||||
ssize_t memleft;
|
size_t memleft;
|
||||||
unsigned bl_version;
|
unsigned bl_version;
|
||||||
|
|
||||||
/* this can only work if Rockbox runs in DRAM, not flash ROM */
|
/* this can only work if Rockbox runs in DRAM, not flash ROM */
|
||||||
|
@ -790,7 +790,7 @@ static void DoUserDialog(char* filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "allocate" memory */
|
/* "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 */
|
if (memleft < SECTORSIZE) /* need buffer for a flash sector */
|
||||||
{
|
{
|
||||||
rb->splash(HZ*3, "Out of memory");
|
rb->splash(HZ*3, "Out of memory");
|
||||||
|
|
|
@ -409,13 +409,13 @@ int load_all_levels(void)
|
||||||
{
|
{
|
||||||
int linecnt = 0;
|
int linecnt = 0;
|
||||||
int fd;
|
int fd;
|
||||||
ssize_t size;
|
size_t size;
|
||||||
char buf[64]; /* Larger than WIDTH, to allow for whitespace after the
|
char buf[64]; /* Larger than WIDTH, to allow for whitespace after the
|
||||||
lines */
|
lines */
|
||||||
|
|
||||||
/* Init the level_cache pointer and
|
/* Init the level_cache pointer and
|
||||||
calculate how many levels that will fit */
|
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);
|
max_levels = size / (HEIGHT*WIDTH);
|
||||||
|
|
||||||
num_levels = 0;
|
num_levels = 0;
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
PLUGIN_HEADER
|
PLUGIN_HEADER
|
||||||
|
|
||||||
ssize_t buf_size;
|
size_t buf_size;
|
||||||
static char *filename;
|
static char *filename;
|
||||||
static int num_entries;
|
static int num_entries;
|
||||||
static char **pointers;
|
static char **pointers;
|
||||||
|
@ -104,7 +104,7 @@ int read_buffer(int offset)
|
||||||
return readsize * 10 - 2;
|
return readsize * 10 - 2;
|
||||||
|
|
||||||
/* Temporary fix until we can do merged sorting */
|
/* Temporary fix until we can do merged sorting */
|
||||||
if(readsize == buf_size)
|
if(readsize == (int)buf_size)
|
||||||
return buf_size; /* File too big */
|
return buf_size; /* File too big */
|
||||||
|
|
||||||
buf_ptr = stringbuffer;
|
buf_ptr = stringbuffer;
|
||||||
|
@ -192,7 +192,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
|
|
||||||
filename = (char *)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;
|
stringbuffer = buf;
|
||||||
pointers = (char **)(buf + buf_size - sizeof(int));
|
pointers = (char **)(buf + buf_size - sizeof(int));
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
PLUGIN_HEADER
|
PLUGIN_HEADER
|
||||||
|
|
||||||
static char *audiobuf;
|
static char *audiobuf;
|
||||||
static ssize_t audiobuflen;
|
static size_t audiobuflen;
|
||||||
unsigned char xingbuf[1500];
|
unsigned char xingbuf[1500];
|
||||||
char tmpname[MAX_PATH];
|
char tmpname[MAX_PATH];
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ enum plugin_status plugin_start(const void *parameter)
|
||||||
if (!parameter)
|
if (!parameter)
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
|
|
||||||
audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen);
|
audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
|
||||||
|
|
||||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
rb->cpu_boost(true);
|
rb->cpu_boost(true);
|
||||||
|
|
|
@ -3059,11 +3059,13 @@ enum plugin_status plugin_start(const void* file)
|
||||||
int lastbutton = BUTTON_NONE;
|
int lastbutton = BUTTON_NONE;
|
||||||
bool autoscroll = false;
|
bool autoscroll = false;
|
||||||
long old_tick;
|
long old_tick;
|
||||||
|
size_t buf_size;
|
||||||
|
|
||||||
old_tick = *rb->current_tick;
|
old_tick = *rb->current_tick;
|
||||||
|
|
||||||
/* get the plugin buffer */
|
/* 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)
|
if (buffer_size == 0)
|
||||||
{
|
{
|
||||||
rb->splash(HZ, "buffer does not allocate !!");
|
rb->splash(HZ, "buffer does not allocate !!");
|
||||||
|
|
|
@ -3649,7 +3649,7 @@ int play_file(char* filename)
|
||||||
/* plugin entry point */
|
/* plugin entry point */
|
||||||
enum plugin_status plugin_start(const void* parameter)
|
enum plugin_status plugin_start(const void* parameter)
|
||||||
{
|
{
|
||||||
ssize_t buf_size;
|
size_t buf_size;
|
||||||
|
|
||||||
if (!parameter)
|
if (!parameter)
|
||||||
{
|
{
|
||||||
|
@ -3657,14 +3657,15 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
return PLUGIN_OK;
|
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 */
|
if (buf_size < 6700) /* needed for i2c transfer */
|
||||||
{
|
{
|
||||||
rb->splash(HZ, "Out of memory.");
|
rb->splash(HZ, "Out of memory.");
|
||||||
return PLUGIN_ERROR;
|
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))
|
switch (play_file((char*)parameter))
|
||||||
{
|
{
|
||||||
|
|
|
@ -3750,14 +3750,14 @@ static int recording_menu(void)
|
||||||
/* plugin entry point */
|
/* plugin entry point */
|
||||||
enum plugin_status plugin_start(const void* parameter)
|
enum plugin_status plugin_start(const void* parameter)
|
||||||
{
|
{
|
||||||
ssize_t buf_size;
|
size_t buf_size;
|
||||||
int align;
|
int align;
|
||||||
int rc;
|
int rc;
|
||||||
const char *recbasedir;
|
const char *recbasedir;
|
||||||
|
|
||||||
(void)parameter;
|
(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 */
|
if (buf_size < 6700) /* needed for i2c transfer */
|
||||||
{
|
{
|
||||||
rb->splash(HZ, "Out of memory.");
|
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;
|
align = (-(long)aud_buf) & 3;
|
||||||
aud_buf += align;
|
aud_buf += align;
|
||||||
aud_size -= align;
|
aud_size -= align;
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct peakstruct
|
||||||
|
|
||||||
/* global vars */
|
/* global vars */
|
||||||
static char *audiobuf;
|
static char *audiobuf;
|
||||||
static ssize_t audiobuflen;
|
static size_t audiobuflen;
|
||||||
static uint32_t mempeakcount = 0;
|
static uint32_t mempeakcount = 0;
|
||||||
static uint32_t filepeakcount = 0;
|
static uint32_t filepeakcount = 0;
|
||||||
static uint32_t fppmp = 0; /* file peaks per mem peaks */
|
static uint32_t fppmp = 0; /* file peaks per mem peaks */
|
||||||
|
@ -362,7 +362,7 @@ enum plugin_status plugin_start(const void *parameter)
|
||||||
if (!parameter)
|
if (!parameter)
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
|
|
||||||
audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen);
|
audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
|
||||||
|
|
||||||
if (!audiobuf)
|
if (!audiobuf)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue