summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/malloc/dmalloc.c26
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
344void *dmalloc(size_t size) 344void *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
488void dfree(void *memp) 488void 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
554void *drealloc(char *ptr, size_t size) 554void *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. */
625void * 625void *
626dcalloc (size_t nmemb, size_t size) 626calloc (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);