Rev 3481 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3481 | Rev 3483 | ||
---|---|---|---|
Line 68... | Line 68... | ||
68 | 68 | ||
69 | cli_errno = CL_EOK; |
69 | cli_errno = CL_EOK; |
70 | return (char *) memcpy(ret, s1, len); |
70 | return (char *) memcpy(ret, s1, len); |
71 | } |
71 | } |
72 | 72 | ||
73 | /* |
- | |
74 | * Take a previously allocated string (s1), re-size it to accept s2 and copy |
- | |
75 | * the contents of s2 into s1. |
- | |
76 | * Return -1 on failure, or the length of the copied string on success. |
- | |
77 | */ |
- | |
78 | size_t cli_redup(char **s1, const char *s2) |
- | |
79 | { |
- | |
80 | size_t len; |
- | |
81 | - | ||
82 | if (s2 == NULL) |
- | |
83 | return -1; |
- | |
84 | - | ||
85 | len = strlen(s2) + 1; |
- | |
86 | - | ||
87 | *s1 = realloc(*s1, len); |
- | |
88 | - | ||
89 | if (*s1 == NULL) { |
- | |
90 | cli_errno = CL_ENOMEM; |
- | |
91 | return -1; |
- | |
92 | } |
- | |
93 | - | ||
94 | *s1[len] = '\0'; |
- | |
95 | - | ||
96 | memcpy(*s1, s2, len); |
- | |
97 | cli_errno = CL_EOK; |
- | |
98 | - | ||
99 | return len; |
- | |
100 | } |
- | |
101 | - | ||
102 | /* Ported from FBSD strtok.c 8.1 (Berkeley) 6/4/93 */ |
73 | /* Ported from FBSD strtok.c 8.1 (Berkeley) 6/4/93 */ |
103 | char * cli_strtok_r(char *s, const char *delim, char **last) |
74 | char * cli_strtok_r(char *s, const char *delim, char **last) |
104 | { |
75 | { |
105 | char *spanp, *tok; |
76 | char *spanp, *tok; |
106 | int c, sc; |
77 | int c, sc; |