Changeset 10976

Show
Ignore:
Timestamp:
06/16/07 12:01:22 (2 years ago)
Author:
piotras
Message:

uri2list: removed unsafe strtok_r usage in favour of g_strsplit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/httpd/apache2/midgard.c

    r10948 r10976  
    183183         
    184184        GList *list = NULL; 
    185         gchar *buf, *s; 
    186         gchar *duri = g_strdup(uri); 
    187  
    188         s = strtok_r((gchar *)duri, "/", &buf); 
    189  
    190         /* This is / request */ 
     185        guint i = 1; 
     186 
     187        gchar **s = g_strsplit(uri, "/", -1); 
     188 
     189        /* This is '/' request */ 
    191190        if(!s) { 
    192                 g_free(duri); 
    193191                return NULL; 
    194192        } 
    195193 
    196194        /* prepend tokens , it's faster than append them */ 
    197         list = g_list_prepend(list, g_strdup(s)); 
    198         while((s = strtok_r(NULL, "/", &buf))) { 
    199                 list = g_list_prepend(list, g_strdup(s));                
    200         } 
    201          
    202         g_free(duri); 
     195        /* note that we start from 1 ( which is empty or null value before '/' ) */ 
     196        while(s[i] != NULL){ 
     197                 
     198                list = g_list_prepend(list, g_strdup(s[i]));             
     199                i++; 
     200        } 
     201         
     202        g_strfreev(s); 
    203203 
    204204        /* Reverse tokens list to get correct order */