Commit 181d1906 authored by Damien George's avatar Damien George
Browse files

stm: Remove unused, useless and not-to-be-used strndup.

Addresses issue #275.
parent f1081f40
......@@ -13,7 +13,6 @@ void *memset(void *s, int c, size_t n);
size_t strlen(const char *str);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
char *strndup(const char *s, size_t n);
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
char *strchr(const char *s, int c);
......
......@@ -78,17 +78,6 @@ int strncmp(const char *s1, const char *s2, size_t n) {
else return 0;
}
char *strndup(const char *s, size_t n) {
size_t len = strlen(s);
if (n > len) {
n = len;
}
char *s2 = malloc(n + 1);
memcpy(s2, s, n);
s2[n] = '\0';
return s2;
}
char *strcpy(char *dest, const char *src) {
char *d = dest;
while (*src) {
......
......@@ -13,7 +13,6 @@ void *memset(void *s, int c, size_t n);
int strlen(const char *str);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
char *strndup(const char *s, size_t n);
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment