On Fri, Mar 03, 2000 at 01:39:56PM +0530, [EMAIL PROTECTED] wrote:
> Sorry Arun,
> 
> thats what i want to ask.
> What my problem is, i had a char ** and allocated memory for it.
> But some how( i am debugging it, its a big program), when i try to free the
> memory pointed by that, i am geeting Segment voilation.
> That's why i want to be sure( before i free it), through some function whether
> that memory is owned by me or not?

Ah, now we're talking. You're probably trying to free memory that's already
free. What you can do is to check if the value of the pointer is greater
than brk(2). If it is, you're guaranteed to get a SIGSEGV.

There are many tools available to solve such problems - purify is a
commercial product which does it, but is not available for Linux. Electric
fence is a free alternative written by Bruce Perens. Search freshmeat for
"memory leak" and you'll find more.

Another way to solve this is write your own system call, which calls
verify_area on the range and returns a result. Wannabe kernel hackers,
this could be a good exercise to get started :)

        -Arun

-----------------------------------------------------------------------
For more information on the LIH mailing list see:
http://lists.linux-india.org/lists/LIH

Reply via email to