summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-26 21:07:40 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-26 21:07:40 +0000
commit3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92 (patch)
tree167e53fa944537c46c61fbe1aa35e3b387f19921 /apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
parent84ea60781319324521d4b5e85a13b0a9e964f7b8 (diff)
downloadrockbox-3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92.tar.gz
rockbox-3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92.zip
Next round of pdbox patches from Wincent Balin: adapt dbestfit to rockbox, ifdef some printfs, and more
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21095 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/dbestfit-3.3/dmalloc.c')
-rw-r--r--apps/plugins/pdbox/dbestfit-3.3/dmalloc.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
index 6ce38cced0..bfc6bdb356 100644
--- a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
+++ b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c
@@ -23,8 +23,13 @@
23 * 23 *
24 *****************************************************************************/ 24 *****************************************************************************/
25 25
26#ifdef ROCKBOX
27#include "plugin.h"
28#define memset rb->memset
29#else /* ROCKBOX */
26#include <stdio.h> 30#include <stdio.h>
27#include <string.h> 31#include <string.h>
32#endif /* ROCKBOX */
28 33
29#ifdef DEBUG 34#ifdef DEBUG
30#include <stdarg.h> 35#include <stdarg.h>
@@ -156,15 +161,23 @@ struct MemInfo {
156 happy with us. 161 happy with us.
157 */ 162 */
158 163
159#if BIGBLOCKS==4060 /* previously */ 164#if defined(BIGBLOCKS) && BIGBLOCKS==4060 /* previously */
165#ifdef ROCKBOX
166unsigned
167#endif /* ROCKBOX */
160short qinfo[]= { 20, 28, 52, 116, 312, 580, 812, 2028 }; 168short qinfo[]= { 20, 28, 52, 116, 312, 580, 812, 2028 };
161#else 169#else
170#ifdef ROCKBOX
171unsigned
172#endif /* ROCKBOX */
162short qinfo[]= { 20, 28, 52, 116, 312, 580, 1016, 2032}; 173short qinfo[]= { 20, 28, 52, 116, 312, 580, 1016, 2032};
163/* 52 and 312 only make use of 4056 bytes, but without them there are too 174/* 52 and 312 only make use of 4056 bytes, but without them there are too
164 wide gaps */ 175 wide gaps */
165#endif 176#endif
166 177
178#ifndef ROCKBOX
167#define MIN(x,y) ((x)<(y)?(x):(y)) 179#define MIN(x,y) ((x)<(y)?(x):(y))
180#endif /* ROCKBOX */
168 181
169/* ---------------------------------------------------------------------- */ 182/* ---------------------------------------------------------------------- */
170/* Globals */ 183/* Globals */
@@ -335,6 +348,9 @@ static void FragBlock(char *memp, int size)
335 **************************************************************************/ 348 **************************************************************************/
336static void initialize(void) 349static void initialize(void)
337{ 350{
351#ifdef ROCKBOX
352 unsigned
353#endif /* ROCKBOX */
338 int i; 354 int i;
339 /* Setup the nmax and fragsize fields of the top structs */ 355 /* Setup the nmax and fragsize fields of the top structs */
340 for(i=0; i< sizeof(qinfo)/sizeof(qinfo[0]); i++) { 356 for(i=0; i< sizeof(qinfo)/sizeof(qinfo[0]); i++) {
@@ -421,7 +437,11 @@ void *dmalloc(size_t size)
421 struct MemTop *memtop=NULL; /* SAFE */ 437 struct MemTop *memtop=NULL; /* SAFE */
422 438
423 /* Determine which queue to use */ 439 /* Determine which queue to use */
440#ifdef ROCKBOX
441 unsigned
442#endif /* ROCKBOX */
424 int queue; 443 int queue;
444
425 for(queue=0; size > qinfo[queue]; queue++) 445 for(queue=0; size > qinfo[queue]; queue++)
426 ; 446 ;
427 do { 447 do {
@@ -622,7 +642,7 @@ void *drealloc(char *ptr, size_t size)
622 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 642 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
623 */ 643 */
624 void *mem=NULL; /* SAFE */ 644 void *mem=NULL; /* SAFE */
625 size_t prevsize; 645 size_t prevsize = 0;
626 646
627 /* NOTE that this is only valid if BLOCK_BIT isn't set: */ 647 /* NOTE that this is only valid if BLOCK_BIT isn't set: */
628 struct MemBlock *block; 648 struct MemBlock *block;