Changeset 1d132ae in mainline
- Timestamp:
- 2008-10-03T09:09:55Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2ef7fd
- Parents:
- d364e94
- Location:
- uspace/app/bdsh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/util.c
rd364e94 r1d132ae 69 69 cli_errno = CL_EOK; 70 70 return (char *) memcpy(ret, s1, len); 71 }72 73 /*74 * Take a previously allocated string (s1), re-size it to accept s2 and copy75 * 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 71 } 101 72 -
uspace/app/bdsh/util.h
rd364e94 r1d132ae 6 6 /* Internal string handlers */ 7 7 extern char * cli_strdup(const char *); 8 extern size_t cli_redup(char **, const char *);9 8 extern char * cli_strtok_r(char *, const char *, char **); 10 9 extern char * cli_strtok(char *, const char *);
Note:
See TracChangeset
for help on using the changeset viewer.