| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | free() |
G'Day Lewin,
-=> Quoting Lewin Edwards to Frank Adam <=-
FA> main()
FA> {
LE> char *local_copy_of_s=foo();
LE> /* process local_copy_of_s */
LE> free(s);
Yes, call it a week long brain fade.:)
LE> But probably a better way is :
LE> main() {
LE> char *s=malloc(256); /* or whatever */
LE> foo(s);
Yes, this is what i normally do, but in this particular case only the
function can calculate the size.Allocing here and reallocing there might
be a bit too much, but was an idea at the time(what's worse it didn't
click then how to free it :))
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.
LE> DON'T DO IT. It will probably work in DOS most of the time unless your
I won't, it was desperation that drove me to try it, and i was surprised
it didn't hang once..:)
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™.