summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2010-05-07 19:27:42 +0000
committerFrank Gevaerts <frank@gevaerts.be>2010-05-07 19:27:42 +0000
commit8d4ff638b9a79abcefe538eef8f1933c0c0decf9 (patch)
treec1071be69e9f794318e6b833e0cb00d0124e77c6
parent6027b9160339bcc9efc80d76b095057e2524be8b (diff)
downloadrockbox-8d4ff638b9a79abcefe538eef8f1933c0c0decf9.tar.gz
rockbox-8d4ff638b9a79abcefe538eef8f1933c0c0decf9.zip
Fix size_t handling in plugin_get_buffer()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25884 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/alpine_cdc.c4
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.c6
-rw-r--r--apps/plugins/dict.c6
-rw-r--r--apps/plugins/firmware_flash.c8
-rw-r--r--apps/plugins/lib/overlay.c4
-rw-r--r--apps/plugins/random_folder_advance_config.c6
-rw-r--r--apps/plugins/rockbox_flash.c8
-rw-r--r--apps/plugins/snake2.c4
-rw-r--r--apps/plugins/sort.c6
-rw-r--r--apps/plugins/vbrfix.c4
-rw-r--r--apps/plugins/viewer.c4
-rw-r--r--apps/plugins/wavplay.c7
-rw-r--r--apps/plugins/wavrecord.c7
-rw-r--r--apps/plugins/wavview.c4
14 files changed, 42 insertions, 36 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 73bc49ff00..9357b2e5ab 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -1141,6 +1141,7 @@ int main(const void* parameter)
1141#ifdef DEBUG 1141#ifdef DEBUG
1142 int button; 1142 int button;
1143#endif 1143#endif
1144 size_t buf_size;
1144 ssize_t stacksize; 1145 ssize_t stacksize;
1145 void* stack; 1146 void* stack;
1146 1147
@@ -1155,7 +1156,8 @@ int main(const void* parameter)
1155#endif 1156#endif
1156 1157
1157 /* init the worker thread */ 1158 /* init the worker thread */
1158 stack = rb->plugin_get_buffer((size_t *)&stacksize); /* use the rest as stack */ 1159 stack = rb->plugin_get_buffer(&buf_size); /* use the rest as stack */
1160 stacksize = buf_size;
1159 stack = (void*)(((unsigned int)stack + 100) & ~3); /* a bit away, 32 bit align */ 1161 stack = (void*)(((unsigned int)stack + 100) & ~3); /* a bit away, 32 bit align */
1160 stacksize = (stacksize - 100) & ~3; 1162 stacksize = (stacksize - 100) & ~3;
1161 if (stacksize < DEFAULT_STACK_SIZE) 1163 if (stacksize < DEFAULT_STACK_SIZE)
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c
index 3d699a7c9e..43da92e0a0 100644
--- a/apps/plugins/chessbox/chessbox_pgn.c
+++ b/apps/plugins/chessbox/chessbox_pgn.c
@@ -32,12 +32,12 @@ short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}};
32 32
33/* global vars for pl_malloc() */ 33/* global vars for pl_malloc() */
34void *bufptr = NULL; 34void *bufptr = NULL;
35ssize_t bufleft; 35size_t bufleft;
36 36
37/* simple function to "allocate" memory in pluginbuffer. 37/* simple function to "allocate" memory in pluginbuffer.
38 * (borrowed from dict.c) 38 * (borrowed from dict.c)
39 */ 39 */
40void *pl_malloc(ssize_t size) 40void *pl_malloc(size_t size)
41{ 41{
42 void *ptr; 42 void *ptr;
43 ptr = bufptr; 43 ptr = bufptr;
@@ -57,7 +57,7 @@ void *pl_malloc(ssize_t size)
57/* init function for pl_malloc() */ 57/* init function for pl_malloc() */
58void pl_malloc_init(void) 58void pl_malloc_init(void)
59{ 59{
60 bufptr = rb->plugin_get_buffer((size_t *)&bufleft); 60 bufptr = rb->plugin_get_buffer(&bufleft);
61} 61}
62 62
63void process_tag(struct pgn_game_node* game, char* buffer){ 63void process_tag(struct pgn_game_node* game, char* buffer){
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c
index cdd4c651de..8c262923b7 100644
--- a/apps/plugins/dict.c
+++ b/apps/plugins/dict.c
@@ -62,10 +62,10 @@ void init_screen(void)
62 62
63/* global vars for pl_malloc() */ 63/* global vars for pl_malloc() */
64void *bufptr; 64void *bufptr;
65ssize_t bufleft; 65size_t bufleft;
66 66
67/* simple function to "allocate" memory in pluginbuffer. */ 67/* simple function to "allocate" memory in pluginbuffer. */
68void *pl_malloc(ssize_t size) 68void *pl_malloc(size_t size)
69{ 69{
70 void *ptr; 70 void *ptr;
71 ptr = bufptr; 71 ptr = bufptr;
@@ -85,7 +85,7 @@ void *pl_malloc(ssize_t size)
85/* init function for pl_malloc() */ 85/* init function for pl_malloc() */
86void pl_malloc_init(void) 86void pl_malloc_init(void)
87{ 87{
88 bufptr = rb->plugin_get_buffer((size_t *)&bufleft); 88 bufptr = rb->plugin_get_buffer(&bufleft);
89} 89}
90 90
91/* for endian problems */ 91/* for endian problems */
diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c
index 6718d58e6a..43ed7a87d9 100644
--- a/apps/plugins/firmware_flash.c
+++ b/apps/plugins/firmware_flash.c
@@ -597,7 +597,7 @@ void DoUserDialog(char* filename)
597 char default_filename[32]; 597 char default_filename[32];
598 int button; 598 int button;
599 int rc; /* generic return code */ 599 int rc; /* generic return code */
600 ssize_t memleft; 600 size_t memleft;
601 tCheckROM result; 601 tCheckROM result;
602 bool is_romless; 602 bool is_romless;
603 603
@@ -644,7 +644,7 @@ void DoUserDialog(char* filename)
644 } 644 }
645 645
646 /* "allocate" memory */ 646 /* "allocate" memory */
647 sector = rb->plugin_get_buffer((size_t *)&memleft); 647 sector = rb->plugin_get_buffer(&memleft);
648 if (memleft < SEC_SIZE) /* need buffer for a flash sector */ 648 if (memleft < SEC_SIZE) /* need buffer for a flash sector */
649 { 649 {
650 rb->splash(HZ*3, "Out of memory"); 650 rb->splash(HZ*3, "Out of memory");
@@ -837,7 +837,7 @@ void DoUserDialog(char* filename)
837 char default_filename[32]; 837 char default_filename[32];
838 int button; 838 int button;
839 int rc; /* generic return code */ 839 int rc; /* generic return code */
840 ssize_t memleft; 840 size_t memleft;
841 tCheckROM result; 841 tCheckROM result;
842 bool is_romless; 842 bool is_romless;
843 843
@@ -884,7 +884,7 @@ void DoUserDialog(char* filename)
884 } 884 }
885 885
886 /* "allocate" memory */ 886 /* "allocate" memory */
887 sector = rb->plugin_get_buffer((size_t *)&memleft); 887 sector = rb->plugin_get_buffer(&memleft);
888 if (memleft < SEC_SIZE) /* need buffer for a flash sector */ 888 if (memleft < SEC_SIZE) /* need buffer for a flash sector */
889 { 889 {
890 rb->splash(HZ*3, "Out of memory"); 890 rb->splash(HZ*3, "Out of memory");
diff --git a/apps/plugins/lib/overlay.c b/apps/plugins/lib/overlay.c
index fb779e4f82..97a6e1c718 100644
--- a/apps/plugins/lib/overlay.c
+++ b/apps/plugins/lib/overlay.c
@@ -49,7 +49,7 @@ enum plugin_status run_overlay(const void* parameter,
49 unsigned char *filename, unsigned char *name) 49 unsigned char *filename, unsigned char *name)
50{ 50{
51 int fd, readsize; 51 int fd, readsize;
52 ssize_t audiobuf_size; 52 size_t audiobuf_size;
53 unsigned char *audiobuf; 53 unsigned char *audiobuf;
54 static struct plugin_header header; 54 static struct plugin_header header;
55 55
@@ -80,7 +80,7 @@ enum plugin_status run_overlay(const void* parameter,
80 return PLUGIN_ERROR; 80 return PLUGIN_ERROR;
81 } 81 }
82 82
83 audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuf_size); 83 audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
84 if (header.load_addr < audiobuf || 84 if (header.load_addr < audiobuf ||
85 header.end_addr > audiobuf + audiobuf_size) 85 header.end_addr > audiobuf + audiobuf_size)
86 { 86 {
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index f7bb790dc1..9a589dfff6 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -33,7 +33,7 @@ static int lasttick;
33#define MAX_REMOVED_DIRS 10 33#define MAX_REMOVED_DIRS 10
34 34
35char *buffer = NULL; 35char *buffer = NULL;
36ssize_t buffer_size; 36size_t buffer_size;
37int num_replaced_dirs = 0; 37int num_replaced_dirs = 0;
38char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH]; 38char removed_dirs[MAX_REMOVED_DIRS][MAX_PATH];
39struct file_format { 39struct file_format {
@@ -248,7 +248,7 @@ int load_list(void)
248 int myfd = rb->open(RFA_FILE,O_RDONLY); 248 int myfd = rb->open(RFA_FILE,O_RDONLY);
249 if (myfd < 0) 249 if (myfd < 0)
250 return -1; 250 return -1;
251 buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size); 251 buffer = rb->plugin_get_audio_buffer(&buffer_size);
252 if (!buffer) 252 if (!buffer)
253 { 253 {
254 return -2; 254 return -2;
@@ -414,7 +414,7 @@ int import_list_from_file_text(void)
414{ 414{
415 char line[MAX_PATH]; 415 char line[MAX_PATH];
416 416
417 buffer = rb->plugin_get_audio_buffer((size_t *)&buffer_size); 417 buffer = rb->plugin_get_audio_buffer(&buffer_size);
418 if (buffer == NULL) 418 if (buffer == NULL)
419 { 419 {
420 rb->splash(HZ*2, "failed to get audio buffer"); 420 rb->splash(HZ*2, "failed to get audio buffer");
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index 4bdb0d2c69..17c5e51ee2 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -568,7 +568,7 @@ static void DoUserDialog(char* filename)
568 int rc; /* generic return code */ 568 int rc; /* generic return code */
569 UINT32 space, aligned_size, true_size; 569 UINT32 space, aligned_size, true_size;
570 UINT8* pos; 570 UINT8* pos;
571 ssize_t memleft; 571 size_t memleft;
572 unsigned bl_version; 572 unsigned bl_version;
573 bool show_greet = false; 573 bool show_greet = false;
574 574
@@ -587,7 +587,7 @@ static void DoUserDialog(char* filename)
587 } 587 }
588 588
589 /* "allocate" memory */ 589 /* "allocate" memory */
590 sector = rb->plugin_get_buffer((size_t *)&memleft); 590 sector = rb->plugin_get_buffer(&memleft);
591 if (memleft < SECTORSIZE) /* need buffer for a flash sector */ 591 if (memleft < SECTORSIZE) /* need buffer for a flash sector */
592 { 592 {
593 rb->splash(HZ*3, "Out of memory"); 593 rb->splash(HZ*3, "Out of memory");
@@ -772,7 +772,7 @@ static void DoUserDialog(char* filename)
772 int rc; /* generic return code */ 772 int rc; /* generic return code */
773 UINT32 space, aligned_size, true_size; 773 UINT32 space, aligned_size, true_size;
774 UINT8* pos; 774 UINT8* pos;
775 ssize_t memleft; 775 size_t memleft;
776 unsigned bl_version; 776 unsigned bl_version;
777 777
778 /* this can only work if Rockbox runs in DRAM, not flash ROM */ 778 /* this can only work if Rockbox runs in DRAM, not flash ROM */
@@ -790,7 +790,7 @@ static void DoUserDialog(char* filename)
790 } 790 }
791 791
792 /* "allocate" memory */ 792 /* "allocate" memory */
793 sector = rb->plugin_get_buffer((size_t *)&memleft); 793 sector = rb->plugin_get_buffer(&memleft);
794 if (memleft < SECTORSIZE) /* need buffer for a flash sector */ 794 if (memleft < SECTORSIZE) /* need buffer for a flash sector */
795 { 795 {
796 rb->splash(HZ*3, "Out of memory"); 796 rb->splash(HZ*3, "Out of memory");
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index d9b6542bf3..414d924c4a 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -409,13 +409,13 @@ int load_all_levels(void)
409{ 409{
410 int linecnt = 0; 410 int linecnt = 0;
411 int fd; 411 int fd;
412 ssize_t size; 412 size_t size;
413 char buf[64]; /* Larger than WIDTH, to allow for whitespace after the 413 char buf[64]; /* Larger than WIDTH, to allow for whitespace after the
414 lines */ 414 lines */
415 415
416 /* Init the level_cache pointer and 416 /* Init the level_cache pointer and
417 calculate how many levels that will fit */ 417 calculate how many levels that will fit */
418 level_cache = rb->plugin_get_buffer((size_t *)&size); 418 level_cache = rb->plugin_get_buffer(&size);
419 max_levels = size / (HEIGHT*WIDTH); 419 max_levels = size / (HEIGHT*WIDTH);
420 420
421 num_levels = 0; 421 num_levels = 0;
diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c
index 05c45cce1e..1e787b33dd 100644
--- a/apps/plugins/sort.c
+++ b/apps/plugins/sort.c
@@ -59,7 +59,7 @@
59 59
60PLUGIN_HEADER 60PLUGIN_HEADER
61 61
62ssize_t buf_size; 62size_t buf_size;
63static char *filename; 63static char *filename;
64static int num_entries; 64static int num_entries;
65static char **pointers; 65static char **pointers;
@@ -104,7 +104,7 @@ int read_buffer(int offset)
104 return readsize * 10 - 2; 104 return readsize * 10 - 2;
105 105
106 /* Temporary fix until we can do merged sorting */ 106 /* Temporary fix until we can do merged sorting */
107 if(readsize == buf_size) 107 if(readsize == (int)buf_size)
108 return buf_size; /* File too big */ 108 return buf_size; /* File too big */
109 109
110 buf_ptr = stringbuffer; 110 buf_ptr = stringbuffer;
@@ -192,7 +192,7 @@ enum plugin_status plugin_start(const void* parameter)
192 192
193 filename = (char *)parameter; 193 filename = (char *)parameter;
194 194
195 buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ 195 buf = rb->plugin_get_audio_buffer(&buf_size); /* start munching memory */
196 196
197 stringbuffer = buf; 197 stringbuffer = buf;
198 pointers = (char **)(buf + buf_size - sizeof(int)); 198 pointers = (char **)(buf + buf_size - sizeof(int));
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 2ca0176084..ba13dc53f9 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -23,7 +23,7 @@
23PLUGIN_HEADER 23PLUGIN_HEADER
24 24
25static char *audiobuf; 25static char *audiobuf;
26static ssize_t audiobuflen; 26static size_t audiobuflen;
27unsigned char xingbuf[1500]; 27unsigned char xingbuf[1500];
28char tmpname[MAX_PATH]; 28char tmpname[MAX_PATH];
29 29
@@ -267,7 +267,7 @@ enum plugin_status plugin_start(const void *parameter)
267 if (!parameter) 267 if (!parameter)
268 return PLUGIN_ERROR; 268 return PLUGIN_ERROR;
269 269
270 audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen); 270 audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
271 271
272#ifdef HAVE_ADJUSTABLE_CPU_FREQ 272#ifdef HAVE_ADJUSTABLE_CPU_FREQ
273 rb->cpu_boost(true); 273 rb->cpu_boost(true);
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index ffed414f68..f000628ca3 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -3059,11 +3059,13 @@ enum plugin_status plugin_start(const void* file)
3059 int lastbutton = BUTTON_NONE; 3059 int lastbutton = BUTTON_NONE;
3060 bool autoscroll = false; 3060 bool autoscroll = false;
3061 long old_tick; 3061 long old_tick;
3062 size_t buf_size;
3062 3063
3063 old_tick = *rb->current_tick; 3064 old_tick = *rb->current_tick;
3064 3065
3065 /* get the plugin buffer */ 3066 /* get the plugin buffer */
3066 buffer = rb->plugin_get_buffer((size_t *)&buffer_size); 3067 buffer = rb->plugin_get_buffer(&buf_size);
3068 buffer_size = buf_size;
3067 if (buffer_size == 0) 3069 if (buffer_size == 0)
3068 { 3070 {
3069 rb->splash(HZ, "buffer does not allocate !!"); 3071 rb->splash(HZ, "buffer does not allocate !!");
diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c
index fdf9535bb2..94fef9faa0 100644
--- a/apps/plugins/wavplay.c
+++ b/apps/plugins/wavplay.c
@@ -3649,7 +3649,7 @@ int play_file(char* filename)
3649/* plugin entry point */ 3649/* plugin entry point */
3650enum plugin_status plugin_start(const void* parameter) 3650enum plugin_status plugin_start(const void* parameter)
3651{ 3651{
3652 ssize_t buf_size; 3652 size_t buf_size;
3653 3653
3654 if (!parameter) 3654 if (!parameter)
3655 { 3655 {
@@ -3657,14 +3657,15 @@ enum plugin_status plugin_start(const void* parameter)
3657 return PLUGIN_OK; 3657 return PLUGIN_OK;
3658 } 3658 }
3659 3659
3660 plug_buf = rb->plugin_get_buffer((size_t *)&buf_size); 3660 plug_buf = rb->plugin_get_buffer(&buf_size);
3661 if (buf_size < 6700) /* needed for i2c transfer */ 3661 if (buf_size < 6700) /* needed for i2c transfer */
3662 { 3662 {
3663 rb->splash(HZ, "Out of memory."); 3663 rb->splash(HZ, "Out of memory.");
3664 return PLUGIN_ERROR; 3664 return PLUGIN_ERROR;
3665 } 3665 }
3666 3666
3667 aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size); 3667 aud_buf = rb->plugin_get_audio_buffer(&buf_size);
3668 aud_size = buf_size;
3668 3669
3669 switch (play_file((char*)parameter)) 3670 switch (play_file((char*)parameter))
3670 { 3671 {
diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c
index f9d76d4366..83b63e9805 100644
--- a/apps/plugins/wavrecord.c
+++ b/apps/plugins/wavrecord.c
@@ -3750,14 +3750,14 @@ static int recording_menu(void)
3750/* plugin entry point */ 3750/* plugin entry point */
3751enum plugin_status plugin_start(const void* parameter) 3751enum plugin_status plugin_start(const void* parameter)
3752{ 3752{
3753 ssize_t buf_size; 3753 size_t buf_size;
3754 int align; 3754 int align;
3755 int rc; 3755 int rc;
3756 const char *recbasedir; 3756 const char *recbasedir;
3757 3757
3758 (void)parameter; 3758 (void)parameter;
3759 3759
3760 plug_buf = rb->plugin_get_buffer((size_t *)&buf_size); 3760 plug_buf = rb->plugin_get_buffer(&buf_size);
3761 if (buf_size < 6700) /* needed for i2c transfer */ 3761 if (buf_size < 6700) /* needed for i2c transfer */
3762 { 3762 {
3763 rb->splash(HZ, "Out of memory."); 3763 rb->splash(HZ, "Out of memory.");
@@ -3776,7 +3776,8 @@ enum plugin_status plugin_start(const void* parameter)
3776 } 3776 }
3777 } 3777 }
3778 3778
3779 aud_buf = rb->plugin_get_audio_buffer((size_t *)&aud_size); 3779 aud_buf = rb->plugin_get_audio_buffer(&buf_size);
3780 aud_size = buf_size;
3780 align = (-(long)aud_buf) & 3; 3781 align = (-(long)aud_buf) & 3;
3781 aud_buf += align; 3782 aud_buf += align;
3782 aud_size -= align; 3783 aud_size -= align;
diff --git a/apps/plugins/wavview.c b/apps/plugins/wavview.c
index 0449fbec05..2b19d3d18a 100644
--- a/apps/plugins/wavview.c
+++ b/apps/plugins/wavview.c
@@ -60,7 +60,7 @@ struct peakstruct
60 60
61/* global vars */ 61/* global vars */
62static char *audiobuf; 62static char *audiobuf;
63static ssize_t audiobuflen; 63static size_t audiobuflen;
64static uint32_t mempeakcount = 0; 64static uint32_t mempeakcount = 0;
65static uint32_t filepeakcount = 0; 65static uint32_t filepeakcount = 0;
66static uint32_t fppmp = 0; /* file peaks per mem peaks */ 66static uint32_t fppmp = 0; /* file peaks per mem peaks */
@@ -362,7 +362,7 @@ enum plugin_status plugin_start(const void *parameter)
362 if (!parameter) 362 if (!parameter)
363 return PLUGIN_ERROR; 363 return PLUGIN_ERROR;
364 364
365 audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuflen); 365 audiobuf = rb->plugin_get_audio_buffer(&audiobuflen);
366 366
367 if (!audiobuf) 367 if (!audiobuf)
368 { 368 {