Skip to content

Commit 181d190

Browse files
committed
stm: Remove unused, useless and not-to-be-used strndup.
Addresses issue adafruit#275.
1 parent f1081f4 commit 181d190

3 files changed

Lines changed: 0 additions & 13 deletions

File tree

stm/std.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ void *memset(void *s, int c, size_t n);
1313
size_t strlen(const char *str);
1414
int strcmp(const char *s1, const char *s2);
1515
int strncmp(const char *s1, const char *s2, size_t n);
16-
char *strndup(const char *s, size_t n);
1716
char *strcpy(char *dest, const char *src);
1817
char *strcat(char *dest, const char *src);
1918
char *strchr(const char *s, int c);

stm/string0.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,6 @@ int strncmp(const char *s1, const char *s2, size_t n) {
7878
else return 0;
7979
}
8080

81-
char *strndup(const char *s, size_t n) {
82-
size_t len = strlen(s);
83-
if (n > len) {
84-
n = len;
85-
}
86-
char *s2 = malloc(n + 1);
87-
memcpy(s2, s, n);
88-
s2[n] = '\0';
89-
return s2;
90-
}
91-
9281
char *strcpy(char *dest, const char *src) {
9382
char *d = dest;
9483
while (*src) {

teensy/std.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ void *memset(void *s, int c, size_t n);
1313
int strlen(const char *str);
1414
int strcmp(const char *s1, const char *s2);
1515
int strncmp(const char *s1, const char *s2, size_t n);
16-
char *strndup(const char *s, size_t n);
1716
char *strcpy(char *dest, const char *src);
1817
char *strcat(char *dest, const char *src);
1918

0 commit comments

Comments
 (0)