Paul Herring wrote:
>
> Out of interest, what lead you to the problem/solution? (I started
> looking into 'parent' allocation, 'child' freeing - and didn't look
> much further.)
>
> --
> PJH
>
> http://shabbleland.myminicity.com/
> http://www.chavgangs.com/register.php?referer=9375
> http://www.kongregate.com/?referrer=Shabble
>
>
Well.
I am not programming very often and have not so many knowledge about the c
language. So it was your hint that I can log the address via syslog and %p.
So I just looked at the addresses of both variables (myip and ip_buffer) and
what happens to them during execution.
The interesting thing was that both variables pointed initially to the same
address after allocation.
ip_buffer = 0x603010
myip = 0x603010
But after the main loop was entered the situation was the following
ip_buffer = 0x605340
myip = 0x7fbb4e4216c8
The programm executed just fine at this point but freeing the address in the
end led to the error
free(): invalid pointer: 0x00007fbb4e4216c8
Then I thought why does one variable get such a long address and the other
one a relatively short address.
The address change happend just after the call to the function get_address()
So I looked inside the function and thought what could be wrong here.
Then I saw that I made the mistake char * = char * function() and used
strcpy(char *, char * function() ) instead. And it worked.
What I still don't understand is why the programm was running correctly
until I tried to free the memory.
Bye Willem
--
View this message in context:
http://www.nabble.com/Linux-signal-Programming-freeing-memory-on-cleanup-tp25391730p25407730.html
Sent from the C-prog mailing list archive at Nabble.com.