diff options
Diffstat (limited to '')
-rw-r--r-- | gc/malloc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gc/malloc.c b/gc/malloc.c index 943f27d..e2db9b4 100644 --- a/gc/malloc.c +++ b/gc/malloc.c @@ -182,6 +182,7 @@ register int k; ptr_t result; DCL_LOCK_STATE; + if (GC_debugging_started) GC_print_all_smashed(); GC_INVOKE_FINALIZERS(); if (SMALL_OBJ(lb)) { DISABLE_SIGNALS(); @@ -337,6 +338,26 @@ DCL_LOCK_STATE; { return((GC_PTR)REDIRECT_MALLOC(n*lb)); } + +#ifndef strdup +# include <string.h> +# ifdef __STDC__ + char *strdup(const char *s) +# else + char *strdup(s) + char *s; +# endif + { + size_t len = strlen(s) + 1; + char * result = ((char *)REDIRECT_MALLOC(len+1)); + BCOPY(s, result, len+1); + return result; + } +#endif /* !defined(strdup) */ + /* If strdup is macro defined, we assume that it actually calls malloc, */ + /* and thus the right thing will happen even without overriding it. */ + /* This seems to be true on most Linux systems. */ + # endif /* REDIRECT_MALLOC */ /* Explicitly deallocate an object p. */ |