James wrote:

> On Sat, 14 Nov 1998, Moshe Zadka wrote:
>
> -Decrefing with a bug?
> -consider the following, buggy, code:
> -a=malloc(10);
> -b=malloc(10);
> -free(a);
> -free(a);
>
> wouldn't the program stop when it reached the 2nd free because it is trying
> to free a NUL pointer

There's no way for the function free to change the value of the
pointer. To do that free should be rewritten to :

void free( void **ptr);

So in ANSI-C when you call free, the pointer in unchanged
( ie stills points to the same location in memory)

> (assuming free sets them to NUL, if not the program

*No Way*

>
> will surely crash as it tries to free some random memory address that it
> probably has no right to alter)

*No way*

I don't know why free causes some segfault when called several times
on the same pointer. ( I don't even know how malloc works.).

>
> these are the kinds of things that make programming such fun! :) (and spending
> 3 hours going through your source all because you typed '<' instead of '>'...)
>
> --
> +++ Divide By Cucumber Error, Please Re-Install Universe And Reboot +++
> [EMAIL PROTECTED]      [Website undergoing re-design...]l.org

--
david Ramboz, [EMAIL PROTECTED]


Reply via email to