summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1997-07-02 19:33:23 +0000
committerphk <phk@FreeBSD.org>1997-07-02 19:33:23 +0000
commit73643318c3a441ade17ebffbe29ea00889ccbad3 (patch)
treea66044557952e2ab7f42faa888623ec0be019b9f /lib/libc
parent1cca29c8abfa13862c4278710bef41754ba399eb (diff)
downloadFreeBSD-src-73643318c3a441ade17ebffbe29ea00889ccbad3.zip
FreeBSD-src-73643318c3a441ade17ebffbe29ea00889ccbad3.tar.gz
Have another go at the malloc-sysv initialization.
PR: 4002 Pointed out by: bde
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/malloc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index acd7e35..88bd04b 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: malloc.c,v 1.26 1997/06/22 17:54:27 phk Exp $
+ * $Id: malloc.c,v 1.27 1997/07/01 18:39:38 phk Exp $
*
*/
@@ -458,9 +458,6 @@ malloc_init ()
malloc_ninfo = malloc_pagesize / sizeof *page_dir;
- /* Been here, done that */
- malloc_started++;
-
/* Recalculate the cache size in bytes, and make sure it's nonzero */
if (!malloc_cache)
@@ -474,6 +471,8 @@ malloc_init ()
*/
px = (struct pgfree *) imalloc (sizeof *px);
+ /* Been here, done that */
+ malloc_started++;
}
/*
@@ -696,9 +695,6 @@ imalloc(size_t size)
{
void *result;
- if (!malloc_started)
- malloc_init();
-
if (suicide)
abort();
@@ -732,11 +728,6 @@ irealloc(void *ptr, size_t size)
if (suicide)
abort();
- if (!malloc_started) {
- wrtwarning("malloc() has never been called.\n");
- return 0;
- }
-
index = ptr2index(ptr);
if (index < malloc_pageshift) {
@@ -1068,6 +1059,8 @@ malloc(size_t size)
malloc_active--;
return (0);
}
+ if (!malloc_started)
+ malloc_init();
if (malloc_sysv && !size)
r = 0;
else
@@ -1109,6 +1102,12 @@ realloc(void *ptr, size_t size)
malloc_active--;
return (0);
}
+ if (ptr && !malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ ptr = 0;
+ }
+ if (!malloc_started)
+ malloc_init();
if (malloc_sysv && !size) {
ifree(ptr);
r = 0;
OpenPOWER on IntegriCloud