help-bison
[Top][All Lists]
Advanced

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

Re: %left is not working


From: Hans Aberg
Subject: Re: %left is not working
Date: Wed, 4 Aug 2010 15:04:01 +0200

On 4 Aug 2010, at 14:17, Sasan Forghani wrote:

I apologize for my lack of understanding. You said the next step is to clean it up in the actions... please clarify?

When you allocate stuff using malloc, strdup, etc. when pointer is not used anymore, to avoid memory leak, one must apply free(). For example, an action might look like
  $$ = malloc(...) // pr something
  // copy over some stuff from the $k values.
Now the, $k values are not used anymore - only $$, so they must be cleaned up using free().

This works if you do not want to do error recovery. For that there is a special function (see the Bison manual).

I do not program in C, but C++, where the language is taking care of this. So perhaps some else might give better examples.


reply via email to

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