#define pVAR register struct perl_vars* my_vars PERL_UNUSED_DECL
+typedef struct interpreter PerlInterpreter;
+
#ifdef PERL_GLOBAL_STRUCT
# define dVAR pVAR = (struct perl_vars*)PERL_GET_VARS()
#else
# define MULTIPLICITY
# endif
# define tTHX PerlInterpreter*
-# define sTHX (sizeof(tTHX) + (MEM_ALIGNBYTES - sizeof(tTHX)%MEM_ALIGNBYTES) % MEM_ALIGNBYTES)
+
+struct perl_memory_debug_header {
+ tTHX interpreter;
+};
+
+# define sTHX (sizeof(struct perl_memory_debug_header) + \
+ (MEM_ALIGNBYTES - sizeof(struct perl_memory_debug_header) \
+ %MEM_ALIGNBYTES) % MEM_ALIGNBYTES)
# define pTHX register tTHX my_perl PERL_UNUSED_DECL
# define aTHX my_perl
# ifdef PERL_GLOBAL_STRUCT
typedef struct pvop PVOP;
typedef struct loop LOOP;
-typedef struct interpreter PerlInterpreter;
-
/* Amdahl's <ksync.h> has struct sv */
/* SGI's <sys/sema.h> has struct sv */
#if defined(UTS) || defined(__sgi)
DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) malloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size));
if (ptr != Nullch) {
#ifdef PERL_TRACK_MEMPOOL
- *(tTHX*)ptr = aTHX;
+ ((struct perl_memory_debug_header *)ptr)->interpreter = aTHX;
ptr = (Malloc_t)((char*)ptr+sTHX);
#endif
return ptr;
#ifdef PERL_TRACK_MEMPOOL
where = (Malloc_t)((char*)where-sTHX);
size += sTHX;
- if (*(tTHX*)where != aTHX) {
+ if (((struct perl_memory_debug_header *)where)->interpreter != aTHX) {
/* int *nowhere = NULL; *nowhere = 0; */
Perl_croak_nocontext("panic: realloc from wrong pool");
}
if (where) {
#ifdef PERL_TRACK_MEMPOOL
where = (Malloc_t)((char*)where-sTHX);
- if (*(tTHX*)where != aTHX) {
+ if (((struct perl_memory_debug_header *)where)->interpreter != aTHX) {
/* int *nowhere = NULL; *nowhere = 0; */
Perl_croak_nocontext("panic: free from wrong pool");
}
if (ptr != Nullch) {
memset((void*)ptr, 0, size);
#ifdef PERL_TRACK_MEMPOOL
- *(tTHX*)ptr = aTHX;
+ ((struct perl_memory_debug_header *)ptr)->interpreter = aTHX;
ptr = (Malloc_t)((char*)ptr+sTHX);
#endif
return ptr;