From 10bae1a1e3b2e34d59fcc3bd839260e58427dd52 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Wed, 1 May 2002 00:06:39 +0000 Subject: [PATCH] Bugzilla bug 131057: define PORT_Strdup as a function that calls PORT_Alloc. Modified files: lib/ckfw/nsprstub.c lib/fortcrypt/swfort/pkcs11/stub.c lib/nss/nss.def lib/util/secport.c lib/util/secport.h --- security/nss/lib/ckfw/nsprstub.c | 4 ++-- security/nss/lib/fortcrypt/swfort/pkcs11/stub.c | 17 +++++++++++++++-- security/nss/lib/nss/nss.def | 1 + security/nss/lib/util/secport.c | 17 +++++++++++++++-- security/nss/lib/util/secport.h | 8 ++++---- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/security/nss/lib/ckfw/nsprstub.c b/security/nss/lib/ckfw/nsprstub.c index 64ff3f0fe9d4..e5c00113d1bf 100644 --- a/security/nss/lib/ckfw/nsprstub.c +++ b/security/nss/lib/ckfw/nsprstub.c @@ -39,7 +39,7 @@ * SW FORTEZZA to link with some low level security functions without dragging * in NSPR. * - * $Id: nsprstub.c,v 1.2 2000/09/11 23:27:56 relyea%netscape.com Exp $ + * $Id: nsprstub.c,v 1.3 2002/05/01 00:06:29 wtc%netscape.com Exp $ */ #include "seccomon.h" @@ -200,7 +200,7 @@ PORT_ArenaUnmark(PLArenaPool *arena, void *mark) } char * -PORT_ArenaStrdup(PLArenaPool *arena,char *str) { +PORT_ArenaStrdup(PLArenaPool *arena,const char *str) { int len = PORT_Strlen(str)+1; char *newstr; diff --git a/security/nss/lib/fortcrypt/swfort/pkcs11/stub.c b/security/nss/lib/fortcrypt/swfort/pkcs11/stub.c index 771c8c51fddf..85d6ad52f753 100644 --- a/security/nss/lib/fortcrypt/swfort/pkcs11/stub.c +++ b/security/nss/lib/fortcrypt/swfort/pkcs11/stub.c @@ -39,7 +39,7 @@ * SW FORTEZZA to link with some low level security functions without dragging * in NSPR. * - * $Id: stub.c,v 1.4 2001/09/20 22:07:33 relyea%netscape.com Exp $ + * $Id: stub.c,v 1.5 2002/05/01 00:06:33 wtc%netscape.com Exp $ */ #include "seccomon.h" @@ -115,6 +115,19 @@ PORT_ZFree(void *ptr, size_t len) } } +char * +PORT_Strdup(const char *str) +{ + size_t len = PORT_Strlen(str)+1; + char *newstr; + + newstr = (char *)PORT_Alloc(len); + if (newstr) { + PORT_Memcpy(newstr, str, len); + } + return newstr; +} + void PORT_SetError(int value) { @@ -210,7 +223,7 @@ PORT_ArenaUnmark(PLArenaPool *arena, void *mark) } char * -PORT_ArenaStrdup(PLArenaPool *arena,char *str) { +PORT_ArenaStrdup(PLArenaPool *arena,const char *str) { int len = PORT_Strlen(str)+1; char *newstr; diff --git a/security/nss/lib/nss/nss.def b/security/nss/lib/nss/nss.def index 38240feac2f2..bb9bf3f7b4de 100644 --- a/security/nss/lib/nss/nss.def +++ b/security/nss/lib/nss/nss.def @@ -675,6 +675,7 @@ CERT_FinishExtensions; CERT_StartCertExtensions; DER_AsciiToTime; PK11_ImportCert; +PORT_Strdup; ;+ local: ;+ *; ;+}; diff --git a/security/nss/lib/util/secport.c b/security/nss/lib/util/secport.c index 694c47da19a5..cad13ac72990 100644 --- a/security/nss/lib/util/secport.c +++ b/security/nss/lib/util/secport.c @@ -38,7 +38,7 @@ * * NOTE - These are not public interfaces * - * $Id: secport.c,v 1.13 2002/04/04 00:11:48 nelsonb%netscape.com Exp $ + * $Id: secport.c,v 1.14 2002/05/01 00:06:39 wtc%netscape.com Exp $ */ #include "seccomon.h" @@ -159,6 +159,19 @@ PORT_ZFree(void *ptr, size_t len) } } +char * +PORT_Strdup(const char *str) +{ + size_t len = PORT_Strlen(str)+1; + char *newstr; + + newstr = (char *)PORT_Alloc(len); + if (newstr) { + PORT_Memcpy(newstr, str, len); + } + return newstr; +} + void PORT_SetError(int value) { @@ -446,7 +459,7 @@ PORT_ArenaUnmark(PLArenaPool *arena, void *mark) } char * -PORT_ArenaStrdup(PLArenaPool *arena, char *str) { +PORT_ArenaStrdup(PLArenaPool *arena, const char *str) { int len = PORT_Strlen(str)+1; char *newstr; diff --git a/security/nss/lib/util/secport.h b/security/nss/lib/util/secport.h index 6bca04406879..40ad224abc79 100644 --- a/security/nss/lib/util/secport.h +++ b/security/nss/lib/util/secport.h @@ -38,7 +38,7 @@ * * NOTE - These are not public interfaces * - * $Id: secport.h,v 1.5 2002/04/04 00:11:48 nelsonb%netscape.com Exp $ + * $Id: secport.h,v 1.6 2002/05/01 00:06:39 wtc%netscape.com Exp $ */ #ifndef _SECPORT_H_ @@ -144,7 +144,7 @@ extern void *PORT_ArenaGrow(PLArenaPool *arena, void *ptr, extern void *PORT_ArenaMark(PLArenaPool *arena); extern void PORT_ArenaRelease(PLArenaPool *arena, void *mark); extern void PORT_ArenaUnmark(PLArenaPool *arena, void *mark); -extern char *PORT_ArenaStrdup(PLArenaPool *arena, char *str); +extern char *PORT_ArenaStrdup(PLArenaPool *arena, const char *str); #ifdef __cplusplus } @@ -210,10 +210,10 @@ extern char *PORT_ArenaStrdup(PLArenaPool *arena, char *str); #define PORT_Strcasecmp PL_strcasecmp #define PORT_Strcat strcat #define PORT_Strchr strchr -#define PORT_Strrchr PL_strrchr +#define PORT_Strrchr strrchr #define PORT_Strcmp strcmp #define PORT_Strcpy strcpy -#define PORT_Strdup PL_strdup +extern char *PORT_Strdup(const char *s); #define PORT_Strlen(s) strlen(s) #define PORT_Strncasecmp PL_strncasecmp #define PORT_Strncat strncat