This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: obstack_mark() and obstack_release()


Hello list,

I needed a specific functionality for obstacks in GCC so I created two new functions, obstack_{mark,release}. In a few words they save and restore the exact obstack state (the base actually) so that any grow() operation can be interrupted and resumed later.

This is only an RFC so the attached patch is against the GCC tree (I believe obstacks are the same) and does not follow the existing macro style, and I provide no official texinfo documentation since I've no experience in that. Please let me know of general comments on the idea and if you think it's worth adding to glibc I'll follow the guidelines you tell me. The documentation could be a new chapter in the following style:



=== Saving and restoring obstack state

There is the possibility of saving the state of the obstack at a certain point and restoring it later, allowing to continue previous operation, either allocating new objects or continue growing the previous object.

obstack_mark
obstack_release

The MARK operation allows you to save the state of the obstack by pushing a special marker onto the stack. When you RELEASE that marker the obstack returns to its previous state which means all memory allocated after the marker is free'd, and most importantly if you were growing an object before pushing the marker, you can now continue growing it. Needless to say that the marker is destroyed if you release/free an earlier marker/object.




I'd appreciate all comments, Dimitris

Attachment: libc-obstacks.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]