summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2006-04-05 21:12:06 +0000
committerwtchang%redhat.com <devnull@localhost>2006-04-05 21:12:06 +0000
commit0120652bf13f1d8bb8544bf73a887c12fbf15e03 (patch)
treecf6eb5f3098c4e443806ad404502c48434c55c8f
parent597c5149dda1c3a9e5041431bef07f52100e1880 (diff)
downloadnspr-hg-0120652bf13f1d8bb8544bf73a887c12fbf15e03.tar.gz
Bugzilla Bug 326168: more cleanups after code review. r=darin,jshin.
Modified files: prlink.h prlink.c w95io.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/include/prlink.h6
-rw-r--r--pr/src/linking/prlink.c25
-rw-r--r--pr/src/md/windows/w95io.c5
3 files changed, 19 insertions, 17 deletions
diff --git a/pr/include/prlink.h b/pr/include/prlink.h
index 0ef3d7ff..f0cea829 100644
--- a/pr/include/prlink.h
+++ b/pr/include/prlink.h
@@ -119,8 +119,8 @@ NSPR_API(PRLibrary*) PR_LoadLibrary(const char *name);
** A code fragment can be specified by name or by an integer index.
**
** Right now PRLibSpec supports four types of library specification:
-** a pathname in the native charset, a Mac code fragment by name,
-** a Mac code fragment by index, and a UTF-16 pathname.
+** a pathname in the native character encoding, a Mac code fragment
+** by name, a Mac code fragment by index, and a UTF-16 pathname.
*/
typedef enum PRLibSpecType {
@@ -165,7 +165,7 @@ typedef struct PRLibSpec {
#define PR_LD_NOW 0x2 /* equivalent to RTLD_NOW on Unix */
#define PR_LD_GLOBAL 0x4 /* equivalent to RTLD_GLOBAL on Unix */
#define PR_LD_LOCAL 0x8 /* equivalent to RTLD_LOCAL on Unix */
-/* 0x400 reserved for NSPR internal use */
+/* 0x8000 reserved for NSPR internal use */
/*
** Load the specified library, in the manner specified by 'flags'.
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index ce2792ac..819ec53e 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -161,9 +161,7 @@ struct _imcb *IAC$GL_IMAGE_LIST = NULL;
#define NEED_LEADING_UNDERSCORE
#endif
-#ifdef WIN32
-#define PR_LD_PATHW 0x400 /* for PR_LibSpec_PathnameU */
-#endif
+#define PR_LD_PATHW 0x8000 /* for PR_LibSpec_PathnameU */
/************************************************************************/
@@ -813,12 +811,14 @@ static PRLibrary*
pr_LoadLibraryByPathname(const char *name, PRIntn flags)
{
PRLibrary *lm;
- PRLibrary* result;
+ PRLibrary* result = NULL;
PRInt32 oserr;
#ifdef WIN32
char utf8name_stack[MAX_PATH];
- PRUnichar wname_stack[MAX_PATH];
+ char *utf8name_malloc = NULL;
char *utf8name = utf8name_stack;
+ PRUnichar wname_stack[MAX_PATH];
+ PRUnichar *wname_malloc = NULL;
PRUnichar *wname = wname_stack;
int len;
#endif
@@ -835,7 +835,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
} else {
int wlen = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
if (wlen > MAX_PATH)
- wname = PR_Malloc(wlen);
+ wname = wname_malloc = PR_Malloc(wlen);
if (wname == NULL ||
!MultiByteToWideChar(CP_ACP, 0, name, -1, wname, wlen)) {
oserr = _MD_ERRNO();
@@ -844,7 +844,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
}
len = pr_ConvertUTF16toUTF8(wname, NULL, 0);
if (len > MAX_PATH)
- utf8name = PR_Malloc(len);
+ utf8name = utf8name_malloc = PR_Malloc(len);
if (utf8name == NULL ||
!pr_ConvertUTF16toUTF8(wname, utf8name, len)) {
oserr = _MD_ERRNO();
@@ -1115,10 +1115,10 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
DLLErrorInternal(oserr); /* sets error text */
}
#ifdef WIN32
- if (utf8name && utf8name != utf8name_stack)
- PR_Free(utf8name);
- if (!(flags & PR_LD_PATHW) && wname && wname != wname_stack)
- PR_Free(wname);
+ if (utf8name_malloc)
+ PR_Free(utf8name_malloc);
+ if (wname_malloc)
+ PR_Free(wname_malloc);
#endif
PR_ExitMonitor(pr_linker_lock);
return result;
@@ -1134,9 +1134,8 @@ static PRStatus
pr_ConvertSingleCharToUTF8(PRUint32 usv, PRUint16 offset, int bufLen,
int *utf8Len, char * *buf)
{
- /* XXX No error checking. Add it for debug build */
char* p = *buf;
- /*if (!bufLen || !*buf) { */
+ PR_ASSERT(!bufLen || *buf);
if (!bufLen) {
*utf8Len += offset;
return PR_SUCCESS;
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index 84641cca..08e7df6a 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -1148,7 +1148,10 @@ static void InitUnicodeSupport(void)
_pr_useUnicode = PR_FALSE;
}
#ifdef DEBUG
- /* In debug builds, allow explicit use of ANSI methods for testing. */
+ /*
+ * In debug builds, allow explicit use of ANSI methods to simulate
+ * a Win9x environment for testing purposes.
+ */
if (getenv("WINAPI_USE_ANSI"))
_pr_useUnicode = PR_FALSE;
#endif