diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-11-17 03:30:10 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-11-17 03:30:10 +0100 |
commit | 5e57b83aae16d44318b9eed1b2cecd0591adc981 (patch) | |
tree | e1cf6290396be7c3251e95606c8a316058ce52a6 /src/string/strdup.c | |
parent | split err.c (diff) | |
download | slibc-5e57b83aae16d44318b9eed1b2cecd0591adc981.tar.gz slibc-5e57b83aae16d44318b9eed1b2cecd0591adc981.tar.bz2 slibc-5e57b83aae16d44318b9eed1b2cecd0591adc981.tar.xz |
m + typo + split (almost all) string/*.c
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/string/strdup.c | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/string/strdup.c b/src/string/strdup.c index 6a66c2c..b7155d7 100644 --- a/src/string/strdup.c +++ b/src/string/strdup.c @@ -36,44 +36,3 @@ char* strdup(const char* string) return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); } - -/** - * Duplicate a string. - * - * This is a GNU extension. - * - * @param string The string to duplicate. - * @param maxlen Truncate the string to this length, if it is longer. - * A NUL byte is guaranteed to always be written - * upon successful completion. - * @return The new string. `NULL` is returned on error - * and `errno` is set to indicate the error. - * - * @throws ENOMEM The process could not allocate sufficient amount of memory. - */ -char* strndup(const char* string, size_t maxlen) -{ - size_t n = strnlen(string, maxlen) + 1; - char* r = malloc(n * sizeof(char)); - return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); -} - - -/** - * Duplicate a memory segment. - * - * This is a slibc extension. - * - * @param segment The memory segment to duplicate. - * @param size The size of the memory segment. - * @return The new segment. `NULL` is returned on error - * and `errno` is set to indicate the error. - * - * @throws ENOMEM The process could not allocate sufficient amount of memory. - */ -void* memdup(const void* segment, size_t size) -{ - void* r = malloc(size); - return r == NULL ? NULL : memcpy(r, segment, size); -} - |