Free memory from list

Esteban Cacavelos <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi all,


I'am having some troubles to free memory from a list

the list item is like that:

typedef struct structT
    {
        Octstr *string2;
        Octstr * string1;
        int varInt1;
        int varInt2;

    }STRUCT_T;

if the list contains N items of type STRUCT_T, how i should free the memory
allocated ?

i did as follow,

STRUCT_T * item;

  for (i = 0  ; i < gwlist_len(my_list); i++)
          {
             item = gwlist_get(my_list,i);
             octstr_destroy(item->string1);
             octstr_destroy (item->string2);
             gw_free(item);

          }//DESTROY ALL ITEMS

          for (i = 0  ; i < gwlist_len(my_list); i++)
          {
             gwlist_delete(my_list, 0, 1);
          }//DESTROY ELEMENTS FROM THE LIST

But, apparently it is not correct or i missing something because the memory
usage of the applicacion grows up.



Thanks,



-- 
Esteban L. Cacavelos de Amoriza
Cel: 0981 220 429
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.