summaryrefslogtreecommitdiff
path: root/firmware/malloc/dmalloc.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-05-16 14:10:28 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-05-16 14:10:28 +0000
commit3eec33f9c64703461875ceaedbd83bbb254315c2 (patch)
treeab9f4c8010ba5bdbba30f78b9ee0f44f6eeb61a3 /firmware/malloc/dmalloc.c
parent4a615c7885ff50a2b49d323ac7ae560ede95d970 (diff)
downloadrockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.zip
rockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.tar.gz
rockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.tar.bz2
rockbox-3eec33f9c64703461875ceaedbd83bbb254315c2.tar.xz
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/dmalloc.c')
-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 1822fdd..cf286e5 100644
--- a/firmware/malloc/dmalloc.c
+++ b/firmware/malloc/dmalloc.c
@@ -37,7 +37,7 @@
#include <psos.h>
#define SEMAPHORE /* the PSOS routines use semaphore protection */
#else
-#include <stdlib.h> /* makes the PSOS complain on the 'size_t' typedef */
+
#endif
#define BMALLOC /* we use our own big-malloc system */
@@ -290,7 +290,7 @@ void dmalloc_initialize(void)
#ifdef SEMAPHORE
{
char name[7];
- sprintf(name, "MEM%d", i);
+ snprintf(name, 7, "MEM%d", i);
SEMAPHORECREATE(name, top[i].semaphore_id);
/* doesn't matter if it failed, we continue anyway ;-( */
}
@@ -341,11 +341,11 @@ static void *fragfromblock(struct MemBlock *block)
*
**************************************************************************/
-void *dmalloc(size_t size)
+void *malloc(size_t size)
{
void *mem;
- DBG(("dmalloc(%d)\n", size));
+ DBG(("malloc(%d)\n", size));
/* First, we make room for the space needed in every allocation */
size += sizeof(struct MemInfo);
@@ -485,12 +485,12 @@ void *dmalloc(size_t size)
*
**************************************************************************/
-void dfree(void *memp)
+void free(void *memp)
{
struct MemInfo *meminfo = (struct MemInfo *)
((char *)memp- sizeof(struct MemInfo));
- DBG(("dfree(%p)\n", memp));
+ DBG(("free(%p)\n", memp));
if(!((size_t)meminfo->block&BLOCK_BIT)) {
/* this is a FRAGMENT we have to deal with */
@@ -551,7 +551,7 @@ void dfree(void *memp)
*
**************************************************************************/
-void *drealloc(char *ptr, size_t size)
+void *realloc(char *ptr, size_t size)
{
struct MemInfo *meminfo = (struct MemInfo *)
((char *)ptr- sizeof(struct MemInfo));
@@ -567,10 +567,10 @@ void *drealloc(char *ptr, size_t size)
/* NOTE that this is only valid if BLOCK_BIT isn't set: */
struct MemBlock *block;
- DBG(("drealloc(%p, %d)\n", ptr, size));
+ DBG(("realloc(%p, %d)\n", ptr, size));
if(NULL == ptr)
- return dmalloc( size );
+ return malloc( size );
block = meminfo->block;
@@ -604,10 +604,10 @@ void *drealloc(char *ptr, size_t size)
/* No tricks involved here, just grab a new bite of memory, copy the
* data from the old place and free the old memory again. */
- mem = dmalloc(size);
+ mem = malloc(size);
if(mem) {
memcpy(mem, ptr, MIN(size, prevsize) );
- dfree(ptr);
+ free(ptr);
}
}
return mem;
@@ -623,9 +623,9 @@ void *drealloc(char *ptr, size_t size)
/* Allocate an array of NMEMB elements each SIZE bytes long.
The entire array is initialized to zeros. */
void *
-dcalloc (size_t nmemb, size_t size)
+calloc (size_t nmemb, size_t size)
{
- void *result = dmalloc (nmemb * size);
+ void *result = malloc (nmemb * size);
if (result != NULL)
memset (result, 0, nmemb * size);