[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Main] Copy user definitions.
From: |
Robert Anisko |
Subject: |
Re: [Main] Copy user definitions. |
Date: |
Tue, 28 Aug 2001 14:05:53 +0200 |
> >> Hi,
> >>
> >> I send you the patch, which copies the user definitions %{...%} in
> >> the bison.simple. Robert tell me what do you think about ?
I like it, there's a nice memory leak!
When do you free definitions?
> >> Index: src/output.c
> >> ===================================================================
> >> RCS file: /cvsroot/bison/bison/src/output.c,v
> >> retrieving revision 1.44
> >> diff -u -r1.44 output.c
> >> --- src/output.c 2001/08/27 14:55:39 1.44
> >> +++ src/output.c 2001/08/28 10:02:48
> >> @@ -1078,6 +1078,15 @@
> >> MACRO_INSERT_INT ("verbose", 0);
> >>
> >> MACRO_INSERT_STRING ("filename", infile);
> >> + {
> >> + size_t size = obstack_object_size (&attrs_obstack);
> >> + char *definitions;
> >> +
> >> + definitions = XMALLOC (char, size + 1);
> >> + bcopy (obstack_finish (&attrs_obstack), definitions, size);
> >> +
> >> + MACRO_INSERT_STRING ("definitions", definitions);
> >> + }
> >>
> >> MACRO_INSERT_INT ("nnts", nvars);
> >> MACRO_INSERT_INT ("nrules", nrules);
> >
> >I do not agree with doing it in prepare ().
>
> This is easy, tell why you are disagree.
I disagree with that too. You do that the quick and
dirty way. I think we should treat definitions
as we treat tables: tables are grown in the output_obstack,
finished as soon as possible, and immediately inserted in the
macro table. I mean, we should not change prepare but
the piece of code that grows attrs_obstack (probably somewhere
in reader).
And I don't understand why do you need to copy the
definitions in a malloc'ed place: you malloc definitions,
you finish attrs_obstack, copy its content to definitions,
and put it back to another obstack. Hey, this is hairy.
You should use the real insertion function, macro_insert,
rather than MACRO_INSERT_STRING, which is a more
specific wrapper.
Why don't you directly grow the definitions in the output_obstack,
and then write: macro_insert ("definitions", obstack_finish
(&output_obstack))?
I think this would more efficient, and more consistent
with the current code.
- [Main] Copy user definitions., Pascal Bart, 2001/08/28
- Re: [Main] Copy user definitions., marc-alexandre autret, 2001/08/28
- Re: [Main] Copy user definitions., Pascal Bart, 2001/08/28
- Re: [Main] Copy user definitions., marc-alexandre autret, 2001/08/28
- Re: [Main] Copy user definitions.,
Robert Anisko <=
- Re: [Main] Copy user definitions., marc-alexandre autret, 2001/08/28
- Re: [Main] Copy user definitions., Robert Anisko, 2001/08/28
- Re: [Main] Copy user definitions., marc-alexandre autret, 2001/08/28
- Re: [Main] Copy user definitions., Akim Demaille, 2001/08/31
Re: [Main] Copy user definitions., Akim Demaille, 2001/08/31
Re: [Main] Copy user definitions., marc-alexandre autret, 2001/08/28