From: Gurusamy Sarathy Date: Mon, 8 Feb 1999 13:23:16 +0000 (+0000) Subject: make safesysmalloc() etc., always available; safemalloc() et al are X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f25172013443eb112285f24a09b83900edb8a738;p=p5sagit%2Fp5-mst-13.2.git make safesysmalloc() etc., always available; safemalloc() et al are now macros that point to the right malloc; fix various places in sources that need to always use safesysmalloc() et al p4raw-id: //depot/perl@2834 --- diff --git a/embed.h b/embed.h index 78c28e2..6fc73ca 100644 --- a/embed.h +++ b/embed.h @@ -788,10 +788,10 @@ #define rxres_free Perl_rxres_free #define rxres_restore Perl_rxres_restore #define rxres_save Perl_rxres_save -#define safecalloc Perl_safecalloc -#define safefree Perl_safefree -#define safemalloc Perl_safemalloc -#define saferealloc Perl_saferealloc +#define safesyscalloc Perl_safesyscalloc +#define safesysfree Perl_safesysfree +#define safesysmalloc Perl_safesysmalloc +#define safesysrealloc Perl_safesysrealloc #define safexcalloc Perl_safexcalloc #define safexfree Perl_safexfree #define safexmalloc Perl_safexmalloc @@ -1947,10 +1947,10 @@ #define rxres_free CPerlObj::Perl_rxres_free #define rxres_restore CPerlObj::Perl_rxres_restore #define rxres_save CPerlObj::Perl_rxres_save -#define safecalloc CPerlObj::Perl_safecalloc -#define safefree CPerlObj::Perl_safefree -#define safemalloc CPerlObj::Perl_safemalloc -#define saferealloc CPerlObj::Perl_saferealloc +#define safesyscalloc CPerlObj::Perl_safesyscalloc +#define safesysfree CPerlObj::Perl_safesysfree +#define safesysmalloc CPerlObj::Perl_safesysmalloc +#define safesysrealloc CPerlObj::Perl_safesysrealloc #define safexcalloc CPerlObj::Perl_safexcalloc #define safexfree CPerlObj::Perl_safexfree #define safexmalloc CPerlObj::Perl_safexmalloc diff --git a/global.sym b/global.sym index 0c6eece..7295be6 100644 --- a/global.sym +++ b/global.sym @@ -435,10 +435,10 @@ runops_standard rxres_free rxres_restore rxres_save -safecalloc -safefree -safemalloc -saferealloc +safesyscalloc +safesysfree +safesysmalloc +safesysrealloc safexcalloc safexfree safexmalloc diff --git a/iperlsys.h b/iperlsys.h index 97f30e3..cfdc39f 100644 --- a/iperlsys.h +++ b/iperlsys.h @@ -610,15 +610,9 @@ public: #else /* PERL_OBJECT */ -#ifdef MYMALLOC -#define PerlMem_malloc(size) Perl_malloc((size)) -#define PerlMem_realloc(buf, size) Perl_realloc((buf), (size)) -#define PerlMem_free(buf) Perl_mfree((buf)) -#else #define PerlMem_malloc(size) malloc((size)) #define PerlMem_realloc(buf, size) realloc((buf), (size)) #define PerlMem_free(buf) free((buf)) -#endif #endif /* PERL_OBJECT */ diff --git a/mg.c b/mg.c index 9547da8..bab5298 100644 --- a/mg.c +++ b/mg.c @@ -880,7 +880,7 @@ magic_clear_all_env(SV *sv, MAGIC *mg) #if defined(VMS) die("Can't make list assignment to %%ENV on this system"); #else -#ifdef WIN32 +# ifdef WIN32 char *envv = GetEnvironmentStrings(); char *cur = envv; STRLEN len; @@ -896,18 +896,21 @@ magic_clear_all_env(SV *sv, MAGIC *mg) cur += len+1; } FreeEnvironmentStrings(envv); -#else +# else +# ifndef PERL_USE_SAFE_PUTENV I32 i; if (environ == PL_origenviron) - New(901, environ, 1, char*); + environ = (char**)safesysmalloc(sizeof(char*)); else for (i = 0; environ[i]; i++) - Safefree(environ[i]); + safesysfree(environ[i]); +# endif /* PERL_USE_SAFE_PUTENV */ + environ[0] = Nullch; -#endif -#endif +# endif /* WIN32 */ +#endif /* VMS */ return 0; } diff --git a/objXSUB.h b/objXSUB.h index 71aa211..0c4efd5 100644 --- a/objXSUB.h +++ b/objXSUB.h @@ -2705,14 +2705,14 @@ #define rxres_restore pPerl->Perl_rxres_restore #undef rxres_save #define rxres_save pPerl->Perl_rxres_save -#undef safecalloc -#define safecalloc pPerl->Perl_safecalloc -#undef safefree -#define safefree pPerl->Perl_safefree -#undef safemalloc -#define safemalloc pPerl->Perl_safemalloc -#undef saferealloc -#define saferealloc pPerl->Perl_saferealloc +#undef safesyscalloc +#define safesyscalloc pPerl->Perl_safesyscalloc +#undef safesysfree +#define safesysfree pPerl->Perl_safesysfree +#undef safesysmalloc +#define safesysmalloc pPerl->Perl_safesysmalloc +#undef safesysrealloc +#define safesysrealloc pPerl->Perl_safesysrealloc #undef safexcalloc #define safexcalloc pPerl->Perl_safexcalloc #undef safexfree diff --git a/perl.h b/perl.h index 206f6be..783f904 100644 --- a/perl.h +++ b/perl.h @@ -400,14 +400,15 @@ Malloc_t Perl_realloc _((Malloc_t where, MEM_SIZE nbytes)); * that causes clashes with case-insensitive linkers */ Free_t Perl_mfree _((Malloc_t where)); -# undef safemalloc -# undef safecalloc -# undef saferealloc -# undef safefree # define safemalloc Perl_malloc # define safecalloc Perl_calloc # define saferealloc Perl_realloc # define safefree Perl_mfree +#else /* MYMALLOC */ +# define safemalloc safesysmalloc +# define safecalloc safesyscalloc +# define saferealloc safesysrealloc +# define safefree safesysfree #endif /* MYMALLOC */ #if defined(STANDARD_C) && defined(I_STDDEF) diff --git a/perl_exp.SH b/perl_exp.SH index 51c3ab2..6bf0d7c 100644 --- a/perl_exp.SH +++ b/perl_exp.SH @@ -100,29 +100,11 @@ perl_call_sv perl_eval_pv perl_eval_sv perl_require_pv -END - -case "$ccflags" in -*-DHIDEMYMALLOC*) - cat >>perl.exp <>perl.exp <) { $debugging_enabled++ if /define\s+DEBUGGING/; - $hide_mymalloc++ if /define\s+EMBEDMYMALLOC/; $use_mymalloc++ if /define\s+MYMALLOC/; } @@ -203,7 +202,7 @@ if ($use_mymalloc) { $fcns{'Perl_malloc'}++; $fcns{'Perl_calloc'}++; $fcns{'Perl_realloc'}++; - $fcns{'Perl_myfree'}++; + $fcns{'Perl_mfree'}++; } $used_expectation_enum = $used_opcode_enum = 0; # avoid warnings diff --git a/win32/makedef.pl b/win32/makedef.pl index 4e60302..0d9069b 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -181,14 +181,9 @@ PL_opsave if ($define{'MYMALLOC'}) { - skip_symbols [qw( - Perl_safefree - Perl_safemalloc - Perl_saferealloc - Perl_safecalloc)]; emit_symbols [qw( Perl_malloc - Perl_free + Perl_mfree Perl_realloc Perl_calloc)]; }