Changeset 561 in MondoRescue for trunk/mondo/mondo/common/libmondo-string.c
- Timestamp:
- May 20, 2006, 5:51:21 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-string.c
r507 r561 2 2 $Id$ 3 3 */ 4 5 4 6 5 /** … … 1139 1138 } 1140 1139 1140 1141 /* New functions safe from a memory manageemnt point of view */ 1142 /* Developped by Andree Leidenfrost */ 1143 1144 char *mr_strtok(char *instr, const char *delims, int *lastpos) { 1145 1146 char *token = NULL; 1147 char *strptr = NULL; 1148 size_t pos1 = 0; 1149 size_t pos2 = 0; 1150 1151 if (strlen(instr) <= *lastpos) { 1152 *lastpos = 0; 1153 return token; 1154 } 1155 1156 strptr = instr + *lastpos; 1157 pos2 = strspn(strptr, delims); 1158 strptr += pos2; 1159 pos1 = strcspn(strptr, delims); 1160 token = malloc(sizeof(*token)*(pos1+1)); 1161 strncpy(token, strptr, pos1); 1162 *lastpos = *lastpos + pos1 + pos2 + 1; 1163 1164 return token; 1165 } 1141 1166 /* @} - end of stringGroup */
Note:
See TracChangeset
for help on using the changeset viewer.