[uClibc-cvs] svn commit: trunk/uClibc/libc/stdlib/malloc-simple
vapier at uclibc.org
vapier at uclibc.org
Thu Jul 7 05:13:26 UTC 2005
Author: vapier
Date: 2005-07-06 23:13:25 -0600 (Wed, 06 Jul 2005)
New Revision: 10735
Log:
Yoshinori Sato writes:
Dont forgive that length of munmap is "0" in current nommu.
This purpose cannot free memory area really.
It is a patch to work out a solution.
Modified:
trunk/uClibc/libc/stdlib/malloc-simple/alloc.c
Changeset:
Modified: trunk/uClibc/libc/stdlib/malloc-simple/alloc.c
===================================================================
--- trunk/uClibc/libc/stdlib/malloc-simple/alloc.c 2005-07-07 04:46:29 UTC (rev 10734)
+++ trunk/uClibc/libc/stdlib/malloc-simple/alloc.c 2005-07-07 05:13:25 UTC (rev 10735)
@@ -1,6 +1,6 @@
/* alloc.c
*
- * Written by Erik Andersen <andersee at debian.org>
+ * Written by Erik Andersen <andersee at codepoet.org>
* LGPLv2
*
* Parts of the memalign code were stolen from malloc-930716.
@@ -32,19 +32,17 @@
}
#ifdef __ARCH_HAS_MMU__
+#define MMAP_FLAGS MAP_PRIVATE | MAP_ANONYMOUS
+#else
+#define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS
+#endif
+
result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+ MMAP_FLAGS, 0, 0);
if (result == MAP_FAILED)
return 0;
* (size_t *) result = size;
return(result + sizeof(size_t));
-#else
- result = mmap((void *) 0, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, 0, 0);
- if (result == MAP_FAILED)
- return 0;
- return(result);
-#endif
}
#endif
@@ -88,11 +86,7 @@
newptr = malloc(size);
if (newptr) {
memcpy(newptr, ptr,
-#ifdef __ARCH_HAS_MMU__
*((size_t *) (ptr - sizeof(size_t)))
-#else
- size
-#endif
);
free(ptr);
}
@@ -111,12 +105,8 @@
return;
}
}
-#ifdef __ARCH_HAS_MMU__
ptr -= sizeof(size_t);
munmap(ptr, * (size_t *) ptr + sizeof(size_t));
-#else
- munmap(ptr, 0);
-#endif
}
#endif
@@ -154,12 +144,8 @@
/* Mark the block as free */
l->aligned = NULL;
ptr = l->exact;
-#ifdef __ARCH_HAS_MMU__
ptr -= sizeof(size_t);
munmap(ptr, * (size_t *) ptr + sizeof(size_t));
-#else
- munmap(ptr, 0);
-#endif
return 1;
}
}
@@ -203,4 +189,3 @@
return result;
}
#endif
-
More information about the uClibc-cvs
mailing list