CreateSemaphoreA handled WINCE_NSPRPUB_RELEASE_4_2_BETA1
authorblythe%netscape.com
Fri, 08 Feb 2002 22:33:59 +0000
branchWINCE_NSPRPUB_RELEASE_4_2_BETA1
changeset 2235 5d359b8e0b9ff964a8fa76acf429f31574d25406
parent 2234 476190c9af4c4de79717b557ccc67000e061a1d6
child 2236 37c1890a4c372ff04c99280920f6a007c800eff3
push idunknown
push userunknown
push dateunknown
CreateSemaphoreA handled
pr/include/md/_win32_unicode.h
pr/src/md/windows/w32ipcsem.c
pr/src/md/windows/w32unicode.c
--- a/pr/include/md/_win32_unicode.h
+++ b/pr/include/md/_win32_unicode.h
@@ -108,11 +108,20 @@ WINAPI
     );
 
 BOOL
 WINAPI
 _MD_RemoveDirectoryA(
     LPCSTR lpPathName
     );
 
+HANDLE
+WINAPI
+_MD_CreateSemaphoreA(
+    IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
+    IN LONG lInitialCount,
+    IN LONG lMaximumCount,
+    IN LPCSTR lpName
+    );
+
 #endif /* WINCE */
 
 #endif /* nspr_win32_unicode_h___ */
--- a/pr/src/md/windows/w32ipcsem.c
+++ b/pr/src/md/windows/w32ipcsem.c
@@ -142,17 +142,17 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
             sa.nLength = sizeof(sa);
             sa.lpSecurityDescriptor = pSD;
             sa.bInheritHandle = FALSE;
             lpSA = &sa;
         }
 #if !defined(WINCE)
         sem->sem = CreateSemaphore(lpSA, value, 0x7fffffff, osname);
 #else
-        sem->sem = CreateSemaphoreA(lpSA, value, 0x7fffffff, osname);
+        sem->sem = _MD_CreateSemaphoreA(lpSA, value, 0x7fffffff, osname);
 #endif
         if (lpSA != NULL) {
             _PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
         }
         if (sem->sem == NULL) {
             _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
             PR_DELETE(sem);
             return NULL;
@@ -184,17 +184,17 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
             return NULL;
         }
 #else
         /*
          * WinCE has odd sematics regarding opening a semaphore.
          * We create the semaphore.  If it existed previouisly, the
          *  state is signaled by GetLastError....
          */
-        sem->sem = CreateSemaphoreA(lpSA, 0, 0x7fffffff, osname);
+        sem->sem = _MD_CreateSemaphoreA(lpSA, 0, 0x7fffffff, osname);
         if(NULL != sem->sem)
         {
             DWORD lastErr = GetLastError();
 
             if(ERROR_ALREADY_EXISTS != lastErr)
             {
                 /*
                  * We created, not opened.
--- a/pr/src/md/windows/w32unicode.c
+++ b/pr/src/md/windows/w32unicode.c
@@ -133,23 +133,27 @@ LPWSTR _PR_MD_A2W(LPCSTR inString, LPWST
 */
 
 VOID
 WINAPI
 OutputDebugStringA(
     LPCSTR lpOutputString
     )
 {
-    LPWSTR str = NULL;
+    LPWSTR wideStr = NULL;
 
-    str = _PR_MD_MALLOC_A2W(lpOutputString);
-    if(NULL != str)
+    wideStr = _PR_MD_MALLOC_A2W(lpOutputString);
+    if(NULL == lpOutputString || NULL != wideStr)
     {
-        OutputDebugStringW(str);
-        PR_Free(str);
+        OutputDebugStringW(wideStr);
+
+        if(NULL != wideStr)
+        {
+            PR_Free(wideStr);
+        }
     }
     else
     {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     }
 }
 
 HINSTANCE
@@ -189,17 +193,17 @@ CreateProcessA (
     LPSTARTUPINFO psiStartInfo,
     LPPROCESS_INFORMATION pProcInfo
     )
 {
     BOOL retval = FALSE;
     LPWSTR wideImageName = NULL;
 
     wideImageName = _PR_MD_MALLOC_A2W(pszImageName);
-    if(NULL != wideImageName)
+    if(NULL == pszImageName || NULL != wideImageName)
     {
         LPWSTR wideCmdLine = NULL;
 
         wideCmdLine = _PR_MD_MALLOC_A2W(pszCmdLine);
         if(NULL == pszCmdLine || NULL != wideCmdLine)
         {
             LPWSTR wideCurDir = NULL;
             WCHAR widePath[MAX_PATH + 1];
@@ -222,17 +226,20 @@ CreateProcessA (
                 PR_Free(wideCmdLine);
             }
         }
         else
         {
             PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
         }
 
-        PR_Free(wideImageName);
+        if(NULL != wideImageName)
+        {
+            PR_Free(wideImageName);
+        }
     }
     else
     {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
     }
 
     return retval;
 }
@@ -401,9 +408,44 @@ WINAPI
     else
     {
         PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);
     }
 
     return retval;
 }
 
+HANDLE
+WINAPI
+_MD_CreateSemaphoreA(
+    IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
+    IN LONG lInitialCount,
+    IN LONG lMaximumCount,
+    IN LPCSTR lpName
+    )
+{
+    HANDLE retval = NULL;
+    LPWSTR wideStr = NULL;
+
+    wideStr = _PR_MD_MALLOC_A2W(lpName);
+    if(NULL == lpName || NULL != wideStr)
+    {
+        retval = CreateSemaphoreW(
+            lpSemaphoreAttributes,
+            lInitialCount,
+            lMaximumCount,
+            wideStr
+            );
+
+        if(NULL != wideStr)
+        {
+            PR_Free(wideStr);
+        }
+    }
+    else
+    {
+        PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
+    }
+
+    return retval;
+}
+
 #endif /* WINCE */
\ No newline at end of file