Re: how do i free memory alloced by mountlist.c / read_filesystem_list ? (fwd)



-----BEGIN PGP SIGNED MESSAGE-----

[Last message bounced, so sending it again ...]

Bruno Widmann <bwidmann@tks.fh-sbg.ac.at> writes:

>         struct mount_entry *mount_list, *me;
>  
>         mount_list = read_filesystem_list (0, 0);
> 
> is used in the diskusage_applet to get fs-status. It's called repeatedly,
> and it return's a pointer to a newly alloced linked list, containing the
> info.

And I'll add a free_filesystem_list () or something similar to it.

> Now my lame question: How to free the memory?

Call free_filesystem_list () which I'll add to mountlist.c.

> I have tried:
> 
>         me = mount_list;
>         while (me) {
>                 mount_list = me;
>                 me = me->me_next;
>                 free(mount_list);
>         }
> 
> 
> after each time it's called, but that doesn't help much.

Basically, this is correct - but you only free the 'me' elements. They
contain pointers to malloced memory too.

Freeing the memory again is very system dependent, so this should be done
in mountlist.c

> any help would be appreciated.

I'm very busy this week, so I'll probably look at it this weekend.

Martin

- -- 
- -----------------------------------------------------------------
   Martin Baulig - Angewandte Mathematik - Universitaet Trier

   baulig@castor.uni-trier.de, http://www.home-of-linux.com/
   Key: 1024-bit key with ID C8178435 created 1997/01/24 
   ID:  67 C1 84 A0 47 F5 11 C5  5F 68 4C 84 99 05 C3 92
   Finger me for public key or fetch finger.txt from the url above
- ------------------------------------------------------------------


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv

iQCVAwUBNYkHS4A8K7jIF4Q1AQFtKQP/StnvR/GDAbniaGl6IN4uw3rMi/0RkHtt
fHPapzd5FL5N4Yo2RZOm7y+gxKJ48LugNW/CfckBtItpu6VWSAIAafAqZJB2tsQU
+bQBe9fS6d3nl7KeRaw2QcmrDxVXmLgp11Fz/pNmfckgeEcGSRb6UXbjTpPXkwex
b+1p3Q29Q3k=
=loBk
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]