bug-m4
[Top][All Lists]
Advanced

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

Re: obstack usage question


From: Eric Blake
Subject: Re: obstack usage question
Date: Tue, 10 Oct 2006 07:17:39 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paul Eggert on 10/9/2006 5:35 PM:
> Eric Blake <address@hidden> writes:
> 
>> that double copy is bothering me; I would really like to reopen a
>> finished object for further growth without having to use temporary
>> storage.  Any thoughts on the matter?  Is this worth taking up with
>> glibc?
> 
> Might be.  How much would it change/slow down the existing code to
> add a new interface to do what you want?
> 

After looking further at the obstack source code, I see no speed impact to
existing uses of obstacks, and only the code growth for the function
counterpart of this, which I think does the trick.  Is the name okay?  Is
it worth adding to gnulib?

/* Reopen OBJ--previously created by obstack_alloc or obstack_finish, and
currently occupying SIZE bytes--for additional growth, freeing any objects
that appeared later on the stack.  SIZE may be smaller than the original
allocated size of OBJ.  */
#define obstack_regrow(OBSTACK, OBJ, SIZE)                              \
  __extension__                                                         \
({ struct obstack *__o = (OBSTACK);                                     \
   void *__obj = (OBJ);                                                 \
   void *__end = (void *)((PTR_INT_TYPE)(OBJ) + (SIZE));                \
   if (__obj > (void *)__o->chunk && __end < (void *)__o->chunk_limit)  \
     {                                                                  \
       __o->next_free = (char *)__end;                                  \
       __o->object_base = (char *)__obj;                                \
     }                                                                  \
   else                                                                 \
     {                                                                  \
       (obstack_free) (__o, __end);                                     \
       __o->object_base = (char *)__obj;                                \
     }                                                                  \
})

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFK51y84KuGfSFAYARAm6rAKCSyxFBZHWyYzyM4DEMgjq3jv2OgQCdFrD2
0nSFzcsAD2MLvNvbSudoR5k=
=VaGb
-----END PGP SIGNATURE-----




reply via email to

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