MCPcopy Create free account
hub / github.com/carbonengine/trinity / yyGrowStack

Function yyGrowStack

shadercompiler/lempar.c:285–310  ·  view source on GitHub ↗

** Try to increase the size of the parser stack. Return the number ** of errors. Return 0 on success. */

Source from the content-addressed store, hash-verified

283** of errors. Return 0 on success.
284*/
285static int yyGrowStack(yyParser *p){
286 int newSize;
287 int idx;
288 yyStackEntry *pNew;
289
290 newSize = p->yystksz*2 + 100;
291 idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
292 if( p->yystack==&p->yystk0 ){
293 pNew = malloc(newSize*sizeof(pNew[0]));
294 if( pNew ) pNew[0] = p->yystk0;
295 }else{
296 pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
297 }
298 if( pNew ){
299 p->yystack = pNew;
300 p->yytos = &p->yystack[idx];
301#ifndef NDEBUG
302 if( yyTraceFILE ){
303 fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n",
304 yyTracePrompt, p->yystksz, newSize);
305 }
306#endif
307 p->yystksz = newSize;
308 }
309 return pNew==0;
310}
311#endif
312
313/* Datatype of the argument to the memory allocated passed as the

Callers 3

ParseInitFunction · 0.70
yy_shiftFunction · 0.70
yy_reduceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected