diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/vmem.h | 23 | ||||
-rw-r--r-- | win32/win32.c | 54 | ||||
-rw-r--r-- | win32/win32iop.h | 17 |
3 files changed, 73 insertions, 21 deletions
diff --git a/win32/vmem.h b/win32/vmem.h index 0fcae27a6c..a0e5eba070 100644 --- a/win32/vmem.h +++ b/win32/vmem.h @@ -143,6 +143,9 @@ protected: long m_lAllocSize; // current alloc size long m_lRefCount; // number of current users CRITICAL_SECTION m_cs; // access lock +#ifdef _DEBUG_MEM + FILE* m_pLog; +#endif }; // #define _DEBUG_MEM @@ -185,6 +188,9 @@ VMem::VMem() ASSERT(bRet); InitializeCriticalSection(&m_cs); +#ifdef _DEBUG_MEM + m_pLog = 0; +#endif Init(); } @@ -193,6 +199,9 @@ VMem::~VMem(void) { ASSERT(HeapValidate(m_hHeap, HEAP_NO_SERIALIZE, NULL)); WALKHEAPTRACE(); +#ifdef _DEBUG_MEM + MemoryUsageMessage(NULL, 0, 0, 0); +#endif DeleteCriticalSection(&m_cs); BOOL bRet = HeapDestroy(m_hHeap); ASSERT(bRet); @@ -642,21 +651,21 @@ void* VMem::Expand(void* block, size_t size) } #ifdef _DEBUG_MEM -#define LOG_FILENAME "P:\\Apps\\Perl\\Result.txt" +#define LOG_FILENAME ".\\MemLog.txt" void MemoryUsageMessage(char *str, long x, long y, int c) { - static FILE* fp = NULL; char szBuffer[512]; if(str) { - if(!fp) - fp = fopen(LOG_FILENAME, "w"); + if(!m_pLog) + m_pLog = fopen(LOG_FILENAME, "w"); sprintf(szBuffer, str, x, y, c); - fputs(szBuffer, fp); + fputs(szBuffer, m_pLog); } else { - fflush(fp); - fclose(fp); + fflush(m_pLog); + fclose(m_pLog); + m_pLog = 0; } } diff --git a/win32/win32.c b/win32/win32.c index 69b7264404..115a66cac7 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1824,6 +1824,8 @@ FAILED: return -1; } +#ifndef PERL_IMPLICIT_CONTEXT + static UINT timerid = 0; static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time) @@ -1834,9 +1836,12 @@ static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time) CALL_FPTR(PL_sighandlerp)(14); } +#endif /* !PERL_IMPLICIT_CONTEXT */ + DllExport unsigned int win32_alarm(unsigned int sec) { +#ifndef PERL_IMPLICIT_CONTEXT /* * the 'obvious' implentation is SetTimer() with a callback * which does whatever receiving SIGALRM would do @@ -1862,6 +1867,7 @@ win32_alarm(unsigned int sec) } } return 0; +#endif /* !PERL_IMPLICIT_CONTEXT */ } #ifdef HAVE_DES_FCRYPT @@ -3271,19 +3277,39 @@ GIVE_UP: * environment and the current directory to CreateProcess */ -void* -get_childenv(void) +DllExport void* +win32_get_childenv(void) { return NULL; } -void -free_childenv(void* d) +DllExport void +win32_free_childenv(void* d) { } -char* -get_childdir(void) +DllExport void +win32_clearenv(void) +{ + char *envv = GetEnvironmentStrings(); + char *cur = envv; + STRLEN len; + while (*cur) { + char *end = strchr(cur,'='); + if (end && end != cur) { + *end = '\0'; + SetEnvironmentVariable(cur, NULL); + *end = '='; + cur = end + strlen(end+1)+2; + } + else if ((len = strlen(cur))) + cur += len+1; + } + FreeEnvironmentStrings(envv); +} + +DllExport char* +win32_get_childdir(void) { dTHX; char* ptr; @@ -3302,8 +3328,8 @@ get_childdir(void) return ptr; } -void -free_childdir(char* d) +DllExport void +win32_free_childdir(char* d) { dTHX; Safefree(d); @@ -3556,12 +3582,12 @@ win32_putchar(int c) #ifndef USE_PERL_SBRK -static char *committed = NULL; -static char *base = NULL; -static char *reserved = NULL; -static char *brk = NULL; -static DWORD pagesize = 0; -static DWORD allocsize = 0; +static char *committed = NULL; /* XXX threadead */ +static char *base = NULL; /* XXX threadead */ +static char *reserved = NULL; /* XXX threadead */ +static char *brk = NULL; /* XXX threadead */ +static DWORD pagesize = 0; /* XXX threadead */ +static DWORD allocsize = 0; /* XXX threadead */ void * sbrk(int need) diff --git a/win32/win32iop.h b/win32/win32iop.h index 4d78839888..51ddb03752 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -145,6 +145,12 @@ DllExport int win32_getpid(void); DllExport char * win32_crypt(const char *txt, const char *salt); +DllExport void * win32_get_childenv(void); +DllExport void win32_free_childenv(void* d); +DllExport void win32_clearenv(void); +DllExport char * win32_get_childdir(void); +DllExport void win32_free_childdir(char* d); + END_EXTERN_C /* @@ -299,6 +305,17 @@ END_EXTERN_C #undef crypt #define crypt(t,s) win32_crypt(t,s) +#undef get_childenv +#undef free_childenv +#undef clearenv +#undef get_childdir +#undef free_childdir +#define get_childenv() win32_get_childenv() +#define free_childenv(d) win32_free_childenv(d) +#define clearenv() win32_clearenv() +#define get_childdir() win32_get_childdir() +#define free_childdir(d) win32_free_childdir(d) + #undef getenv #define getenv win32_getenv #undef putenv |