Changeset 371bd7d in mainline for uspace/lib/c/generic/str.c
- Timestamp:
- 2010-03-27T09:22:17Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 36a75a2
- Parents:
- cd82bb1 (diff), eaf22d4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/lib/c/generic/str.c (moved) (moved from uspace/lib/libc/generic/string.c ) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
rcd82bb1 r371bd7d 34 34 */ 35 35 36 #include <str ing.h>36 #include <str.h> 37 37 #include <stdlib.h> 38 38 #include <assert.h> … … 43 43 #include <align.h> 44 44 #include <mem.h> 45 #include <str ing.h>45 #include <str.h> 46 46 47 47 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 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 898 925 899 926 /** Convert initial part of string to unsigned long according to given base. … … 920 947 } 921 948 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 933 949 char *strtok(char *s, const char *delim) 934 950 {
Note:
See TracChangeset
for help on using the changeset viewer.
