| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | free() |
G'Day Peter,
-=> Quoting Peter Collis to Frank Adam <=-
PC> should work just fine just don't forget to add the 'return' to the end
PC> of your foo function.
i don't think the compiler will let me forget :)
FA> says "what s?" of course.
PC> have a pointer ready to accept the return pointer value.
thanks, i've had a complete mental shutdown on this, as soon as i saw
the first reply it clicked that it's the same memory location.
FA> I also believe that in a multitask environment, that would be
FA> fatal if another program got a slice between free() and return,
PC> not sure if i understand what you mean here?.
Well i imagined a scenario, where Prog1 is running in conjunction
with Prog2, Prog1 goes off and does it's thing in foo() and just as it
executed the free(str) statement, OS steps in and gives Prog2 a slice
Prog2 happens to be looking for memory and comes across a "free" block
where Prog1's str lives, and happily populates it...
When Prog1 gets it's slice back it goes and returns ptr which is no
longer the same animal, promptly hanging the machine or do something weird.
Then i'd go and bash ctrl+alt+delete yelling how i hate intermittent bugs,
and probably spend ages finding it, because it's likely to work just fine
in the debugger.
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™.