Skip to content

Commit ae0c5ef

Browse files
authored
Merge pull request #300 from dgarske/str_funcs
Use the internal version of `strdup `
2 parents 20bf416 + f2498d8 commit ae0c5ef

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

wolfssh/port.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,45 +288,45 @@ extern "C" {
288288
#include <string.h>
289289
#endif
290290

291-
WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int);
292-
WOLFSSH_API char* wstrncat(char*, const char*, size_t);
293-
294291
#define WMEMCPY(d,s,l) memcpy((d),(s),(l))
295292
#define WMEMSET(b,c,l) memset((b),(c),(l))
296293
#define WMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
297294
#define WMEMMOVE(d,s,l) memmove((d),(s),(l))
298295

299296
#define WSTRLEN(s1) strlen((s1))
300297
#define WSTRSTR(s1,s2) strstr((s1),(s2))
301-
#define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n))
302298
#define WSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
303-
#define WSTRNCAT(s1,s2,n) wstrncat((s1),(s2),(n))
304299
#define WSTRSPN(s1,s2) strspn((s1),(s2))
305300
#define WSTRCSPN(s1,s2) strcspn((s1),(s2))
306301

302+
/* for these string functions use internal versions */
303+
WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int);
304+
WOLFSSH_API char* wstrncat(char*, const char*, size_t);
305+
WOLFSSL_API char* wstrdup(const char*, void*, int);
306+
#define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n))
307+
#define WSTRNCAT(s1,s2,n) wstrncat((s1),(s2),(n))
308+
#define WSTRDUP(s,h,t) wstrdup((s),(h),(t))
309+
307310
#ifdef USE_WINDOWS_API
308311
#define WSTRNCPY(s1,s2,n) strncpy_s((s1),(n),(s2),(n))
309312
#define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
310313
#define WSNPRINTF(s,n,f,...) _snprintf_s((s),(n),(n),(f),##__VA_ARGS__)
311314
#define WVSNPRINTF(s,n,f,...) _vsnprintf_s((s),(n),(n),(f),##__VA_ARGS__)
312315
#define WSTRTOK(s1,s2,s3) strtok_s((s1),(s2),(s3))
313-
#define WSTRDUP(s,h,t) _strdup((s))
314316
#elif defined(MICROCHIP_MPLAB_HARMONY) || defined(MICROCHIP_PIC32)
315317
#include <stdio.h>
316318
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
317319
#define WSTRNCASECMP(s1, s2, n) strncmp((s1), (s2), (n))
318320
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__)
319321
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__)
320322
#define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3))
321-
#define WSTRDUP(s,h,t) strdup((s))
322323
#elif defined(RENESAS_CSPLUS)
323324
#include <stdio.h>
324325
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
325326
#define WSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
326327
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),__VA_ARGS__)
327328
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),__VA_ARGS__)
328329
#define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3))
329-
#define WSTRDUP(s,h,t) strdup((s))
330330
#else
331331
#ifndef FREESCALE_MQX
332332
#include <stdio.h>
@@ -336,8 +336,6 @@ extern "C" {
336336
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__)
337337
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__)
338338
#define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3))
339-
WOLFSSL_API char* wstrdup(const char*, void*, int);
340-
#define WSTRDUP(s,h,t) wstrdup((s),(h),(t))
341339
#endif
342340
#endif /* WSTRING_USER */
343341

0 commit comments

Comments
 (0)