Changeset 24410
- Timestamp:
- 10/18/13 12:24:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/titan/global.h
r24408 r24410 269 269 } 270 270 271 char **str_split(char *string, char *delim) { 271 char **str_split(char *string, char *delim) 272 { 272 273 char **tokens = NULL; 273 274 char *working = NULL; 274 275 char *token = NULL; 275 276 int idx = 0; 276 277 tokens = malloc(sizeof(char *) * MAXTOKENS); 277 278 if(string == NULL) return NULL; 279 280 tokens = malloc(sizeof(char*) * MAXTOKENS); 278 281 if(tokens == NULL) 279 282 return NULL; … … 292 295 293 296 /* always keep the last entry NULL termindated */ 294 while((idx < (MAXTOKENS - 1)) && (token != NULL)) { 297 while(idx < (MAXTOKENS - 1) && token != NULL) 298 { 295 299 tokens[idx] = malloc(sizeof(char) * strlen(token) + 1); 296 if(tokens[idx] != NULL) { 300 if(tokens[idx] != NULL) 301 { 297 302 strcpy(tokens[idx], token); 298 303 idx++;
Note: See TracChangeset
for help on using the changeset viewer.