Rev 4234 | Rev 4265 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4234 | Rev 4264 | ||
---|---|---|---|
Line 604... | Line 604... | ||
604 | str[i - 1] = str[i]; |
604 | str[i - 1] = str[i]; |
605 | 605 | ||
606 | return true; |
606 | return true; |
607 | } |
607 | } |
608 | 608 | ||
609 | /** Count the number of characters in the string, not including terminating 0. |
- | |
610 | * |
- | |
611 | * @param str String. |
- | |
612 | * @return Number of characters in string. |
- | |
613 | */ |
- | |
614 | size_t strlen(const char *str) |
- | |
615 | { |
- | |
616 | size_t counter = 0; |
- | |
617 | - | ||
618 | while (str[counter] != 0) |
- | |
619 | counter++; |
- | |
620 | - | ||
621 | return counter; |
- | |
622 | } |
- | |
623 | - | ||
624 | int strcmp(const char *a, const char *b) |
- | |
625 | { |
- | |
626 | int c = 0; |
- | |
627 | - | ||
628 | while (a[c] && b[c] && (!(a[c] - b[c]))) |
- | |
629 | c++; |
- | |
630 | - | ||
631 | return (a[c] - b[c]); |
- | |
632 | } |
- | |
633 | - | ||
634 | int strncmp(const char *a, const char *b, size_t n) |
609 | int strncmp(const char *a, const char *b, size_t n) |
635 | { |
610 | { |
636 | size_t c = 0; |
611 | size_t c = 0; |
637 | 612 | ||
638 | while (c < n && a[c] && b[c] && (!(a[c] - b[c]))) |
613 | while (c < n && a[c] && b[c] && (!(a[c] - b[c]))) |
Line 868... | Line 843... | ||
868 | return orig; |
843 | return orig; |
869 | } |
844 | } |
870 | 845 | ||
871 | char * strdup(const char *s1) |
846 | char * strdup(const char *s1) |
872 | { |
847 | { |
873 | size_t len = strlen(s1) + 1; |
848 | size_t len = str_size(s1) + 1; |
874 | void *ret = malloc(len); |
849 | void *ret = malloc(len); |
875 | 850 | ||
876 | if (ret == NULL) |
851 | if (ret == NULL) |
877 | return (char *) NULL; |
852 | return (char *) NULL; |
878 | 853 |