Hi,

>        In my program (written in C under Linux OS) whenever, 
>wherever
>free() call appears, it creates a run time error.The same progam 
>is very fine
>without the free() calls. Is there anything to do with the 
>compiler flags?

This problem generally occurs if you are deallocating more memory 
than you allocated.

Say you had used sizeof("Ar you there") while using malloc and 
when freeing you try to free sizeof("Are you there"), then notice 
that I am trying to deallocate 1 extra character here (Are and 
Ar). So, the system will coredump promptly at the free and not at 
allocation. In fact if you use strcpy to copy "Are you there" to 
the allocated string variable, it will work fine enough, until it 
comes to the free() call. Such errors are sometimes difficult to 
catch, as both strings seem the same if seen side by side.

Regards,

Venky

HCL Technologies, Noida

On Thu, 11 Apr 2002 Arindam Bhattacharjee wrote :
>Hello,
>       Although it is a Linux UG and not a C UG, yet can someone 
>please solve my
>one problem. In my program (written in C under Linux OS) 
>whenever, wherever
>free() call appears, it creates a run time error.The same progam 
>is very fine
>without the free() calls. Is there anything to do with the 
>compiler flags?
>Can someone please help.
>Arindam
>
>           ================================================
>To subscribe, send email to [EMAIL PROTECTED] with subscribe 
>in subject header
>To unsubscribe, send email to [EMAIL PROTECTED] with 
>unsubscribe in subject header
>Archives are available at 
>http://www.mail-archive.com/ilugd%40wpaa.org
>           =================================================
>


          ================================================
To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header
To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header
Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org
          =================================================

Reply via email to