A89: Re: when malloc fails...


[Prev][Next][Index][Thread]

A89: Re: when malloc fails...




> Consider the following scenario:
> In a C program, some function attempts to malloc() memory and fails due to
> the lack of available RAM. Apparently, the program must exit(). But If I do
> so, what happens to the memory that was previously allocated on the calling
> level? Is it leaked? If it is, do I handle a situation like this?

TIOS won't exit() the program if a memory allocation fails (unless TIGCC has
implemented it that way). Instead, you'll get a null pointer or handle returned
from the function, so it's up to you to free all the memory you've allocated. In
most cases you shouldn't have to use malloc() though.

In a related topic, does TIGCC support BSS blocks yet? Can the TIOS support it?

--
 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF v5.1 Quote follows:

- "You pay for it before you eat it? What happens if it's dreadful?"
- "That's why."
        -- (Terry Pratchett, Moving Pictures)





Follow-Ups: References: