Changes in uspace/lib/libc/generic/string.c [fc6dd18:b67c7d64] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/string.c
rfc6dd18 rb67c7d64 896 896 } 897 897 898 char *str_dup(const char *src)899 {900 size_t size = str_size(src);901 void *dest = malloc(size + 1);902 903 if (dest == NULL)904 return (char *) NULL;905 906 return (char *) memcpy(dest, src, size + 1);907 }908 909 char *str_ndup(const char *src, size_t max_size)910 {911 size_t size = str_size(src);912 if (size > max_size)913 size = max_size;914 915 char *dest = (char *) malloc(size + 1);916 917 if (dest == NULL)918 return (char *) NULL;919 920 memcpy(dest, src, size);921 dest[size] = 0;922 return dest;923 }924 925 898 926 899 /** Convert initial part of string to unsigned long according to given base. … … 947 920 } 948 921 922 char *str_dup(const char *src) 923 { 924 size_t size = str_size(src); 925 void *dest = malloc(size + 1); 926 927 if (dest == NULL) 928 return (char *) NULL; 929 930 return (char *) memcpy(dest, src, size + 1); 931 } 932 949 933 char *strtok(char *s, const char *delim) 950 934 {
Note:
See TracChangeset
for help on using the changeset viewer.