The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Your friend, "realloc", munger of heaps. by LionsPhil2004-02-10 16:05:14
  I assume that you want to retain by Slamlander 2004-02-10 18:13:36
whatever is in the buffer? No, don't free() or you will lose it. Copy it to a local var and then free(). Then try a malloc(). If you still don't have enough then your compiler is set to a to-low value of local space. Try to get more from a shared segment. If that doesn't work then ABEND because you have other, more serious, problems.

What we used to have to do, in the old days, is calculate the max worst case memory usage and predeclare that in the compiler's switches [I'm talking Lattice C v3.2, under IBM PC-DOS, circa 1987 here]. This day and age, you shouldn't have to do that. Somehow, your executable doesn't have enough allocatable RAM and the OS isn't giving you any more.

Generally, if realloc() doesn't work then it's about to crash anyway.
[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)