Skip to content

Commit 8ca9c33

Browse files
committed
Remove unnecessary String re-implementations from PAL
1 parent 4b9fe7e commit 8ca9c33

File tree

18 files changed

+34
-447
lines changed

18 files changed

+34
-447
lines changed

pal/inc/mbusafecrt.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ extern errno_t wcsncpy_s( WCHAR* outDest, size_t inDestBufferSize, const WCHAR*
6464
extern char* strtok_s( char* inString, const char* inControl, char** ioContext );
6565
extern WCHAR* wcstok_s( WCHAR* inString, const WCHAR* inControl, WCHAR** ioContext );
6666

67-
// strnlen is not required unless the source string is completely untrusted (e.g. anonymous input on a website)
68-
#ifndef SUPPRESS_STRNLEN
69-
extern size_t strnlen( const char* inString, size_t inMaxSize );
70-
extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );
71-
#endif
67+
extern size_t wcsnlen( const WCHAR* inString, size_t inMaxSize );
7268

7369
extern errno_t _itoa_s( int inValue, char* outBuffer, size_t inDestBufferSize, int inRadix );
7470
extern errno_t _itow_s( int inValue, WCHAR* outBuffer, size_t inDestBufferSize, int inRadix );

pal/inc/pal.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Module Name:
4545
#include <stdlib.h>
4646
#include <stdarg.h>
4747
#include <string.h>
48+
#include <strings.h>
4849
#include <errno.h>
4950
#include <ctype.h>
5051
#endif
@@ -6103,7 +6104,6 @@ CoCreateGuid(OUT GUID * pguid);
61036104
#define vswprintf PAL_vswprintf
61046105
#define fopen PAL_fopen
61056106
#define strtok PAL_strtok
6106-
#define strtoul PAL_strtoul
61076107
#define fprintf PAL_fprintf
61086108
#define fwprintf PAL_fwprintf
61096109
#define vfprintf PAL_vfprintf
@@ -6137,7 +6137,6 @@ CoCreateGuid(OUT GUID * pguid);
61376137
#define mkstemp PAL_mkstemp
61386138
#define rename PAL_rename
61396139
#define unlink PAL_unlink
6140-
#define _strdup PAL__strdup
61416140
#define _getcwd PAL__getcwd
61426141
#define _open PAL__open
61436142
#define _close PAL__close
@@ -6180,7 +6179,6 @@ PALIMPORT void * __cdecl memchr(const void *, int, size_t);
61806179
PALIMPORT size_t __cdecl strlen(const char *);
61816180
PALIMPORT int __cdecl strcmp(const char*, const char *);
61826181
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
6183-
PALIMPORT int __cdecl _strnicmp(const char *, const char *, size_t);
61846182
PALIMPORT char * __cdecl strcat(char *, const char *);
61856183
PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
61866184
PALIMPORT char * __cdecl strcpy(char *, const char *);
@@ -6198,7 +6196,7 @@ PALIMPORT int __cdecl sscanf(const char *, const char *, ...);
61986196
PALIMPORT int __cdecl atoi(const char *);
61996197
PALIMPORT LONG __cdecl atol(const char *);
62006198
//PALIMPORT long long int __cdecl atoll(const char *) __THROW;
6201-
PALIMPORT ULONG __cdecl strtoul(const char *, char **, int);
6199+
PALIMPORT unsigned long __cdecl strtoul(const char *, char **, int);
62026200
PALIMPORT double __cdecl atof(const char *);
62036201
PALIMPORT double __cdecl strtod(const char *, char **);
62046202
PALIMPORT int __cdecl isprint(int);
@@ -6218,7 +6216,7 @@ PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
62186216
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
62196217
PALIMPORT void * __cdecl memmove_xplat(void *, const void *, size_t);
62206218
PALIMPORT char * __cdecl _strlwr(char *);
6221-
PALIMPORT int __cdecl _stricmp(const char *, const char *);
6219+
PALIMPORT int __cdecl strcasecmp(const char *, const char *);
62226220
PALIMPORT int __cdecl _snprintf(char *, size_t, const char *, ...);
62236221
PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
62246222
PALIMPORT char * __cdecl _ecvt(double, int, int *, int *);

pal/inc/rt/safecrt.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,34 +2409,11 @@ unsigned char * __cdecl _mbstok_s(unsigned char *_String, const unsigned char *_
24092409
#endif /* _SAFECRT_DEFINE_MBS_FUNCTIONS */
24102410

24112411
#ifndef PAL_STDCPP_COMPAT
2412-
/* strnlen */
24132412
/*
2414-
* strnlen, wcsnlen ;
2413+
* wcsnlen ;
24152414
* returns inMaxSize if the null character is not found.
24162415
*/
2417-
_SAFECRT__EXTERN_C
2418-
size_t __cdecl strnlen(const char* inString, size_t inMaxSize);
2419-
2420-
#if _SAFECRT_USE_INLINES || _SAFECRT_IMPL
2421-
2422-
_SAFECRT__INLINE
2423-
size_t __cdecl strnlen(const char* inString, size_t inMaxSize)
2424-
{
2425-
size_t n;
2426-
2427-
/* Note that we do not check if s == nullptr, because we do not
2428-
* return errno_t...
2429-
*/
2430-
2431-
for (n = 0; n < inMaxSize && *inString; n++, inString++)
2432-
;
2433-
2434-
return n;
2435-
}
2436-
2437-
#endif
24382416

2439-
/* wcsnlen */
24402417
_SAFECRT__EXTERN_C
24412418
size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize);
24422419

pal/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ set(SOURCES
9999
cruntime/printf.cpp
100100
cruntime/printfcpp.cpp
101101
cruntime/silent_printf.cpp
102-
cruntime/string.cpp
103102
cruntime/stringtls.cpp
104103
cruntime/thread.cpp
105104
cruntime/wchar.cpp

pal/src/cruntime/file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ PAL_fopen(const char * fileName, const char * mode)
283283
goto done;
284284
}
285285

286-
UnixFileName = PAL__strdup(fileName);
286+
UnixFileName = strdup(fileName);
287287
if (UnixFileName == NULL )
288288
{
289-
ERROR("PAL__strdup() failed\n");
289+
ERROR("strdup() failed\n");
290290
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
291291
goto done;
292292
}

pal/src/cruntime/malloc.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,3 @@ CorUnix::InternalMalloc(
114114
pvMem = (void*)malloc(szSize);
115115
return pvMem;
116116
}
117-
118-
char *
119-
__cdecl
120-
PAL__strdup(
121-
const char *c_szStr
122-
)
123-
{
124-
return InternalStrdup(c_szStr);
125-
}
126-
127-
char *
128-
CorUnix::InternalStrdup(
129-
const char *c_szStr
130-
)
131-
{
132-
char *pszStrCopy;
133-
pszStrCopy = strdup(c_szStr);
134-
return pszStrCopy;
135-
}

pal/src/cruntime/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ BOOL MiscPutenv(const char *string, BOOL deleteIfEmpty)
433433
// See if we are replacing an item or adding one.
434434

435435
// Make our copy up front, since we'll use it either way.
436-
copy = InternalStrdup(string);
436+
copy = strdup(string);
437437
if (copy == NULL)
438438
{
439439
goto done;

0 commit comments

Comments
 (0)