X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fperlhost.h;h=c8a0406b6c9964b0cc0a4acbd54944ffce32ecfb;hb=25ca88e0cbd385e70d7ea2ee4f8a34a9ff7bcc17;hp=b68f5c771bf1d2b2a0918517d38e7e4d1fc0d2b0;hpb=4a9d61009ab1e3df94ef4ecfcc453c9ce73010a4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/perlhost.h b/win32/perlhost.h index b68f5c7..c8a0406 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -1136,7 +1136,7 @@ PerlDirClose(struct IPerlDir* piPerl, DIR *dirp) } DIR* -PerlDirOpen(struct IPerlDir* piPerl, char *filename) +PerlDirOpen(struct IPerlDir* piPerl, const char *filename) { return win32_opendir(filename); } @@ -1719,7 +1719,9 @@ win32_start_child(LPVOID arg) sv_setiv(sv, -(IV)w32_pseudo_id); SvREADONLY_on(sv); } +#ifdef PERL_USES_PL_PIDSTATUS hv_clear(PL_pidstatus); +#endif /* push a zero on the stack (we are the child) */ { @@ -1750,7 +1752,7 @@ restart: PL_curstash = PL_defstash; if (PL_endav && !PL_minus_c) call_list(oldscope, PL_endav); - status = STATUS_NATIVE_EXPORT; + status = STATUS_EXIT; break; case 3: if (PL_restartop) { @@ -1774,9 +1776,9 @@ restart: win32_checkTLS(my_perl); /* close the std handles to avoid fd leaks */ { - do_close(gv_fetchpv("STDIN", TRUE, SVt_PVIO), FALSE); - do_close(gv_fetchpv("STDOUT", TRUE, SVt_PVIO), FALSE); - do_close(gv_fetchpv("STDERR", TRUE, SVt_PVIO), FALSE); + do_close(PL_stdingv, FALSE); + do_close(gv_fetchpv("STDOUT", TRUE, SVt_PVIO), FALSE); /* PL_stdoutgv - ISAGN */ + do_close(PL_stderrgv, FALSE); } /* destroy everything (waits for any pseudo-forked children) */ @@ -2057,7 +2059,7 @@ CPerlHost::CPerlHost(CPerlHost& host) CPerlHost::~CPerlHost(void) { -// Reset(); + Reset(); InterlockedDecrement(&num_hosts); delete m_pvDir; m_pVMemParse->Release(); @@ -2118,6 +2120,8 @@ lookup(const void *arg1, const void *arg2) LPSTR* CPerlHost::Lookup(LPCSTR lpStr) { + if (!lpStr) + return NULL; return (LPSTR*)bsearch(&lpStr, m_lppEnvList, m_dwEnvCount, sizeof(LPSTR), lookup); } @@ -2169,20 +2173,24 @@ CPerlHost::Add(LPCSTR lpStr) // replacing ? lpPtr = Lookup(szBuffer); - if(lpPtr != NULL) { - Renew(*lpPtr, length, char); + if (lpPtr != NULL) { + // must allocate things via host memory allocation functions + // rather than perl's Renew() et al, as the perl interpreter + // may either not be initialized enough when we allocate these, + // or may already be dead when we go to free these + *lpPtr = (char*)Realloc(*lpPtr, length * sizeof(char)); strcpy(*lpPtr, lpStr); } else { - ++m_dwEnvCount; - Renew(m_lppEnvList, m_dwEnvCount, LPSTR); - New(1, m_lppEnvList[m_dwEnvCount-1], length, char); - if(m_lppEnvList[m_dwEnvCount-1] != NULL) { - strcpy(m_lppEnvList[m_dwEnvCount-1], lpStr); - qsort(m_lppEnvList, m_dwEnvCount, sizeof(LPSTR), compare); + m_lppEnvList = (LPSTR*)Realloc(m_lppEnvList, (m_dwEnvCount+1) * sizeof(LPSTR)); + if (m_lppEnvList) { + m_lppEnvList[m_dwEnvCount] = (char*)Malloc(length * sizeof(char)); + if (m_lppEnvList[m_dwEnvCount] != NULL) { + strcpy(m_lppEnvList[m_dwEnvCount], lpStr); + ++m_dwEnvCount; + qsort(m_lppEnvList, m_dwEnvCount, sizeof(LPSTR), compare); + } } - else - --m_dwEnvCount; } } @@ -2210,7 +2218,7 @@ CPerlHost::GetChildDir(void) dTHX; int length; char* ptr; - New(0, ptr, MAX_PATH+1, char); + Newx(ptr, MAX_PATH+1, char); if(ptr) { m_pvDir->GetCurrentDirectoryA(MAX_PATH+1, ptr); length = strlen(ptr); @@ -2257,7 +2265,7 @@ CPerlHost::CreateLocalEnvironmentStrings(VDir &vDir) // add the additional space used by changes made to the environment dwSize += CalculateEnvironmentSpace(); - New(1, lpStr, dwSize, char); + Newx(lpStr, dwSize, char); lpPtr = lpStr; if(lpStr != NULL) { // build the local environment @@ -2325,11 +2333,13 @@ CPerlHost::Reset(void) dTHX; if(m_lppEnvList != NULL) { for(DWORD index = 0; index < m_dwEnvCount; ++index) { - Safefree(m_lppEnvList[index]); + Free(m_lppEnvList[index]); m_lppEnvList[index] = NULL; } } m_dwEnvCount = 0; + Free(m_lppEnvList); + m_lppEnvList = NULL; } void