chiark / gitweb /
[PATCH] update klibc to version 0.181
[elogind.git] / klibc / klibc / malloc.c
index 20a2350d71b70b77e7355fb9e5a5d5d07bf682ba..976353c2016b1c138b084a9b01075edf1b9895a6 100644 (file)
@@ -133,9 +133,14 @@ void *malloc(size_t size)
   }
 
   /* Nothing found... need to request a block from the kernel */
-  fsize = (size+MALLOC_CHUNK_MASK) & ~MALLOC_CHUNK_MASK; 
+  fsize = (size+MALLOC_CHUNK_MASK) & ~MALLOC_CHUNK_MASK;
+
+#ifdef MALLOC_USING_SBRK
+  fp = (struct free_arena_header *) sbrk(fsize);
+#else
   fp = (struct free_arena_header *)
     mmap(NULL, fsize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+#endif
 
   if ( fp == (struct free_arena_header *)MAP_FAILED ) {
     return NULL;               /* Failed to get a block */