Rev 4265 | Rev 4268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4265 | Rev 4266 | ||
|---|---|---|---|
| Line 38... | Line 38... | ||
| 38 | #include <limits.h> |
38 | #include <limits.h> |
| 39 | #include <ctype.h> |
39 | #include <ctype.h> |
| 40 | #include <malloc.h> |
40 | #include <malloc.h> |
| 41 | #include <errno.h> |
41 | #include <errno.h> |
| 42 | #include <align.h> |
42 | #include <align.h> |
| - | 43 | #include <mem.h> |
|
| 43 | #include <string.h> |
44 | #include <string.h> |
| 44 | 45 | ||
| 45 | /** Byte mask consisting of lowest @n bits (out of 8) */ |
46 | /** Byte mask consisting of lowest @n bits (out of 8) */ |
| 46 | #define LO_MASK_8(n) ((uint8_t) ((1 << (n)) - 1)) |
47 | #define LO_MASK_8(n) ((uint8_t) ((1 << (n)) - 1)) |
| 47 | 48 | ||
| Line 804... | Line 805... | ||
| 804 | while ((*(dest++) = *(src++))) |
805 | while ((*(dest++) = *(src++))) |
| 805 | ; |
806 | ; |
| 806 | return orig; |
807 | return orig; |
| 807 | } |
808 | } |
| 808 | 809 | ||
| 809 | char *strncpy(char *dest, const char *src, size_t n) |
- | |
| 810 | { |
- | |
| 811 | char *orig = dest; |
- | |
| 812 | - | ||
| 813 | while ((*(dest++) = *(src++)) && --n) |
- | |
| 814 | ; |
- | |
| 815 | return orig; |
- | |
| 816 | } |
- | |
| 817 | - | ||
| 818 | char *strcat(char *dest, const char *src) |
810 | char *strcat(char *dest, const char *src) |
| 819 | { |
811 | { |
| 820 | char *orig = dest; |
812 | char *orig = dest; |
| 821 | while (*dest++) |
813 | while (*dest++) |
| 822 | ; |
814 | ; |
| Line 824... | Line 816... | ||
| 824 | while ((*dest++ = *src++)) |
816 | while ((*dest++ = *src++)) |
| 825 | ; |
817 | ; |
| 826 | return orig; |
818 | return orig; |
| 827 | } |
819 | } |
| 828 | 820 | ||
| 829 | char * strdup(const char *s1) |
821 | char *str_dup(const char *src) |
| 830 | { |
822 | { |
| 831 | size_t len = str_size(s1) + 1; |
823 | size_t size = str_size(src); |
| 832 | void *ret = malloc(len); |
824 | void *dest = malloc(size + 1); |
| 833 | 825 | ||
| 834 | if (ret == NULL) |
826 | if (dest == NULL) |
| 835 | return (char *) NULL; |
827 | return (char *) NULL; |
| 836 | 828 | ||
| 837 | return (char *) memcpy(ret, s1, len); |
829 | return (char *) memcpy(dest, src, size + 1); |
| 838 | } |
830 | } |
| 839 | 831 | ||
| 840 | char *strtok(char *s, const char *delim) |
832 | char *strtok(char *s, const char *delim) |
| 841 | { |
833 | { |
| 842 | static char *next; |
834 | static char *next; |