| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | free() |
G'Day Paul,
-=> Quoting Paul Edwards to Frank Adam <=-
FA> If it is, how would i then get access to s to free it ? It's out of
PE> How do you get access to s to USE it in the first place? Surely
PE> you are going something like this:
PE> t = foo();
PE> ???
PE> If so, then to free the memory, just go free(t);
That loud crash was my head hitting the desk :), thanks.
FA> Btw, i have thought about freeing it before returning, and it *seems* to
FA> work fine in DOS, but i don't know how safe that is.
PE> This is quite confusing, but I think what you mean is you free it
PE> and you CONTINUE to use it. That is as unsafe as jumping off the
No, i meant returning the freed pointer and copying straight away into
s'thing else, i did assume that was quite safe as i can't see what else
could get access to that part of the memory before the copy, but later
i thought that bad things could happen if another program gets a slice
and overwrites that memory, rightly assuming it's free(which it would be).
eg: strcpy(myval,foo());
..which would be very inefficient to say the least.
Anyway problem solved , thanks again.
L8r Frank (fadam{at}ozemail.com.au).
___ Blue Wave/DOS v2.21
--- Maximus 3.01
* Origin: The Software Parlour (3:635/544)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413 SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/544 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.