Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for libcfg+/src/platon/str/strdyn.c between version 1.12 and 1.13

version 1.12, 2001/12/05 23:58:48 version 1.13, 2001/12/08 18:23:53
Line 141  char **strdyn_add_ar(char **ar, char * c
Line 141  char **strdyn_add_ar(char **ar, char * c
         return ar;          return ar;
 }  }
   
   char **strdyn_remove_idx(char **ar, int idx)
   {
           register int i;
   
           for (i = 0; ar[i] != NULL; i++) {
                   if (i == idx)
                           free(ar[i]);
   
                   if (i >= idx)
                           ar[i] = ar[i + 1];
           }
   
           if ((ar = (char**) realloc(ar, i * sizeof(char*))) == NULL)
                   return NULL;
   
           return ar;
   }
   
   char **strdyn_remove_str(char **ar, char *s)
   {
           register int idx;
   
           idx = strdyn_search(ar, s);
   
           if (idx < 0)
                   return ar;
   
           return strdyn_remove_idx(ar, idx);
   }
   
   char **strdyn_remove_str_all(char **ar, char *s)
   {
           char **new_ar = NULL;
   
           while (new_ar != ar) {
                   if (new_ar != NULL)
                           ar = new_ar;
   
                   if ((new_ar = strdyn_remove_str(ar, s)) == NULL)
                           return NULL;
           }
   
           return ar;
   }
   
 char **strdyn_remove_empty(char **ar)  char **strdyn_remove_empty(char **ar)
 {  {
         register int i, j;          register int i, j;
Line 300  char *strdyn_implode_str(char **ar, char
Line 345  char *strdyn_implode_str(char **ar, char
   
         sep_size = strlen(sep);          sep_size = strlen(sep);
   
         for (i = 0, str_size = 0; ar[i] != NULL; )          for (i = 0, str_size = 0; ar[i] != NULL; i++)
                 str_size += strlen(ar[i++]) + sep_size;                  str_size += strlen(ar[i]) + sep_size;
   
           str_size -= sep_size;
   
         if ((str = (char*) malloc(str_size * sizeof(char))) == NULL)          if ((str = (char*) malloc((str_size + 1) * sizeof(char))) == NULL)
                 return NULL;                  return NULL;
   
         for (i = 0,     s = str; ar[i] != NULL; i++) {          for (i = 0,     s = str; ar[i] != NULL; i++) {

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top