Changeset 24410


Ignore:
Timestamp:
10/18/13 12:24:23 (10 years ago)
Author:
nit
Message:

[titan] cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/global.h

    r24408 r24410  
    269269}
    270270
    271 char **str_split(char *string, char *delim) {
     271char **str_split(char *string, char *delim)
     272{
    272273        char **tokens = NULL;
    273274        char *working = NULL;
    274275        char *token = NULL;
    275276        int idx = 0;
    276 
    277         tokens  = malloc(sizeof(char *) * MAXTOKENS);
     277       
     278        if(string == NULL) return NULL;
     279
     280        tokens = malloc(sizeof(char*) * MAXTOKENS);
    278281        if(tokens == NULL)
    279282                return NULL;
     
    292295
    293296        /* always keep the last entry NULL termindated */
    294         while((idx < (MAXTOKENS - 1)) && (token != NULL)) {
     297        while(idx < (MAXTOKENS - 1) && token != NULL)
     298        {
    295299                tokens[idx] = malloc(sizeof(char) * strlen(token) + 1);
    296                 if(tokens[idx] != NULL) {
     300                if(tokens[idx] != NULL)
     301                {
    297302                        strcpy(tokens[idx], token);
    298303                        idx++;
Note: See TracChangeset for help on using the changeset viewer.