Re: [uClinux-dev] how to use a free function to free a space from malloc ?

From: Casey Jaymes (cjaymes@yahoo.com)
Date: Thu Sep 19 2002 - 09:07:02 EDT


The perror() call always happens. free() may set errno (what perror()
uses to generate its message) but this behavior is undefined. I don't
believe there is a way to see if the memory is actually free()'d, and I
would just assume that it was. Just be sure you don't call free() twice.

Casey

On Wed, 2002-09-18 at 11:56, JINGSONG LIU wrote:
>  
> All : Does someone know how to use a free function to free a space from
> malloc ?<?xml:namespace prefix = o ns =
> "urn:schemas-microsoft-com:office:office" />
> Problem I met is that I got message "load=>free invalid argument" when issue
> A free function. See a testing code as follows: 
>  
> I use uClibc and 2.4 version to make this testing code.
> =================================================================
> static      unsigned char *luc;
> 
> int test_free()
> {
>       
>       if ((luc = (unsigned char *)malloc(90000)) == NULL) {
>             perror("load=>mallock");
>             return -1;
>       }
>       else 
>             perror("load=>mallock");
> 
>     if (luc) {
>             free(luc);
>             perror("load=>free");
>       }
>  
> return 1;
> }
> ==================================================================
>  
> Thanks in advance 
> Jason Liu
>  



This message resent by the uclinux-dev@uclinux.org list server http://www.uClinux.org/

This archive was generated by hypermail 2.1.4 : Thu Sep 19 2002 - 13:21:55 EDT