help-bison
[Top][All Lists]
Advanced

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

Re: Reporting malloc failure in actions


From: Joe Nelson
Subject: Re: Reporting malloc failure in actions
Date: Wed, 30 Dec 2020 12:18:01 -0600

Akim Demaille wrote:
> >     if (!(bla = malloc(n)))
> >             goto yyexhaustedlab;
>
> I guess most people just fail here, and don't even try to recover from
> memory exhaustion.  Out of curiosity: do you really manage to keep
> your program working after you've run out of memory?

In my case I'm making a library that people can link with to parse
certain data formats. It currently calls abort() if malloc fails, but I
thought it should give the caller an opportunity to recover if possible.
Don't know all situations where the library might be used, so I prefer
to fail gracefully.

> I don't think this area (yyexhaustedlab) would change, but you are right
> it is an internal detail.  I'll add something public in the future,
> maybe YYNOMEM.  Any idea of a good spelling for such a macro?
> YYEXHAUSTED doesn't sound right.

Thank you! YYNOMEM sounds good to me. :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]