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: Thu, 31 Dec 2020 11:40:52 -0600

Christian Schoenebeck wrote:
> > #ifdef YYNOMEM
> >     /* newer bison version */
> >     YYNOMEM;
> > #else
> >     /* older bison (undocumented feature) */
> >     goto yyexhaustedlab;
> > #endif
> 
> You would be dealing with internals, but AFAICS that internal label
> already exists for decades, so it'll be okay as pragmatic solution I
> guess.

Just realized another problem -- I don't think I can use goto across
functions like this. And even if the goto was valid in parser_alloc(),
I'll need YYNOMEM for other functions, like strdup(). The simplest thing
to do is probably shim YYNOMEM in my parser and use it directly:

#ifndef YYNOMEM
#define YYNOMEM goto yyexhaustedlab
#endif



reply via email to

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