Create a destroy function for your structure, then use
gwlist_destroy(list, your_destroy_function); to destroy the list and
all contained data.

Thanks,
Donald

On 2/23/10, Esteban Cacavelos <estebancacave...@gmail.com> wrote:
> 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
>


-- 
Donald Jackson
http://www.elite-sms-software.com
http://www.ddj.co.za
http://www.thearchitech.com
donald(a)thearchitech.com

Reply via email to