diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-05-16 14:10:28 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-05-16 14:10:28 +0000 |
commit | 3eec33f9c64703461875ceaedbd83bbb254315c2 (patch) | |
tree | ab9f4c8010ba5bdbba30f78b9ee0f44f6eeb61a3 /firmware/malloc | |
parent | 4a615c7885ff50a2b49d323ac7ae560ede95d970 (diff) | |
download | rockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.tar.gz rockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.zip |
renamed to use the common names: malloc/free/realloc/calloc
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@594 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/malloc')
-rw-r--r-- | firmware/malloc/dmalloc.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/firmware/malloc/dmalloc.c b/firmware/malloc/dmalloc.c index 1822fdda52..cf286e54b4 100644 --- a/firmware/malloc/dmalloc.c +++ b/firmware/malloc/dmalloc.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <psos.h> | 37 | #include <psos.h> |
38 | #define SEMAPHORE /* the PSOS routines use semaphore protection */ | 38 | #define SEMAPHORE /* the PSOS routines use semaphore protection */ |
39 | #else | 39 | #else |
40 | #include <stdlib.h> /* makes the PSOS complain on the 'size_t' typedef */ | 40 | |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #define BMALLOC /* we use our own big-malloc system */ | 43 | #define BMALLOC /* we use our own big-malloc system */ |
@@ -290,7 +290,7 @@ void dmalloc_initialize(void) | |||
290 | #ifdef SEMAPHORE | 290 | #ifdef SEMAPHORE |
291 | { | 291 | { |
292 | char name[7]; | 292 | char name[7]; |
293 | sprintf(name, "MEM%d", i); | 293 | snprintf(name, 7, "MEM%d", i); |
294 | SEMAPHORECREATE(name, top[i].semaphore_id); | 294 | SEMAPHORECREATE(name, top[i].semaphore_id); |
295 | /* doesn't matter if it failed, we continue anyway ;-( */ | 295 | /* doesn't matter if it failed, we continue anyway ;-( */ |
296 | } | 296 | } |
@@ -341,11 +341,11 @@ static void *fragfromblock(struct MemBlock *block) | |||
341 | * | 341 | * |
342 | **************************************************************************/ | 342 | **************************************************************************/ |
343 | 343 | ||
344 | void *dmalloc(size_t size) | 344 | void *malloc(size_t size) |
345 | { | 345 | { |
346 | void *mem; | 346 | void *mem; |
347 | 347 | ||
348 | DBG(("dmalloc(%d)\n", size)); | 348 | DBG(("malloc(%d)\n", size)); |
349 | 349 | ||
350 | /* First, we make room for the space needed in every allocation */ | 350 | /* First, we make room for the space needed in every allocation */ |
351 | size += sizeof(struct MemInfo); | 351 | size += sizeof(struct MemInfo); |
@@ -485,12 +485,12 @@ void *dmalloc(size_t size) | |||
485 | * | 485 | * |
486 | **************************************************************************/ | 486 | **************************************************************************/ |
487 | 487 | ||
488 | void dfree(void *memp) | 488 | void free(void *memp) |
489 | { | 489 | { |
490 | struct MemInfo *meminfo = (struct MemInfo *) | 490 | struct MemInfo *meminfo = (struct MemInfo *) |
491 | ((char *)memp- sizeof(struct MemInfo)); | 491 | ((char *)memp- sizeof(struct MemInfo)); |
492 | 492 | ||
493 | DBG(("dfree(%p)\n", memp)); | 493 | DBG(("free(%p)\n", memp)); |
494 | 494 | ||
495 | if(!((size_t)meminfo->block&BLOCK_BIT)) { | 495 | if(!((size_t)meminfo->block&BLOCK_BIT)) { |
496 | /* this is a FRAGMENT we have to deal with */ | 496 | /* this is a FRAGMENT we have to deal with */ |
@@ -551,7 +551,7 @@ void dfree(void *memp) | |||
551 | * | 551 | * |
552 | **************************************************************************/ | 552 | **************************************************************************/ |
553 | 553 | ||
554 | void *drealloc(char *ptr, size_t size) | 554 | void *realloc(char *ptr, size_t size) |
555 | { | 555 | { |
556 | struct MemInfo *meminfo = (struct MemInfo *) | 556 | struct MemInfo *meminfo = (struct MemInfo *) |
557 | ((char *)ptr- sizeof(struct MemInfo)); | 557 | ((char *)ptr- sizeof(struct MemInfo)); |
@@ -567,10 +567,10 @@ void *drealloc(char *ptr, size_t size) | |||
567 | /* NOTE that this is only valid if BLOCK_BIT isn't set: */ | 567 | /* NOTE that this is only valid if BLOCK_BIT isn't set: */ |
568 | struct MemBlock *block; | 568 | struct MemBlock *block; |
569 | 569 | ||
570 | DBG(("drealloc(%p, %d)\n", ptr, size)); | 570 | DBG(("realloc(%p, %d)\n", ptr, size)); |
571 | 571 | ||
572 | if(NULL == ptr) | 572 | if(NULL == ptr) |
573 | return dmalloc( size ); | 573 | return malloc( size ); |
574 | 574 | ||
575 | block = meminfo->block; | 575 | block = meminfo->block; |
576 | 576 | ||
@@ -604,10 +604,10 @@ void *drealloc(char *ptr, size_t size) | |||
604 | 604 | ||
605 | /* No tricks involved here, just grab a new bite of memory, copy the | 605 | /* No tricks involved here, just grab a new bite of memory, copy the |
606 | * data from the old place and free the old memory again. */ | 606 | * data from the old place and free the old memory again. */ |
607 | mem = dmalloc(size); | 607 | mem = malloc(size); |
608 | if(mem) { | 608 | if(mem) { |
609 | memcpy(mem, ptr, MIN(size, prevsize) ); | 609 | memcpy(mem, ptr, MIN(size, prevsize) ); |
610 | dfree(ptr); | 610 | free(ptr); |
611 | } | 611 | } |
612 | } | 612 | } |
613 | return mem; | 613 | return mem; |
@@ -623,9 +623,9 @@ void *drealloc(char *ptr, size_t size) | |||
623 | /* Allocate an array of NMEMB elements each SIZE bytes long. | 623 | /* Allocate an array of NMEMB elements each SIZE bytes long. |
624 | The entire array is initialized to zeros. */ | 624 | The entire array is initialized to zeros. */ |
625 | void * | 625 | void * |
626 | dcalloc (size_t nmemb, size_t size) | 626 | calloc (size_t nmemb, size_t size) |
627 | { | 627 | { |
628 | void *result = dmalloc (nmemb * size); | 628 | void *result = malloc (nmemb * size); |
629 | 629 | ||
630 | if (result != NULL) | 630 | if (result != NULL) |
631 | memset (result, 0, nmemb * size); | 631 | memset (result, 0, nmemb * size); |