[Gc] New API function (GC_objdup)

Ivan Maidanski ivmai at mail.ru
Wed Dec 4 00:26:57 PST 2013


 Hi Bruce,

The idea looks good to me. Does anyone have an idea how to have the requested functionality w/o adding a new function to GC?
Anyway, please provide a link to your commit on github (it would simplify contribution process).

Thank you

Wed,  4 Dec 2013, 10:40 +13:00 from Bruce Hoult <bruce at hoult.org>:
>Hi Ivan,
>
>..., for something I'm doing at the moment I feel a need for a function similar to GC_realloc(), except it doesn't free the old object (and doesn't change the size).
>
>I'm calling it GC_objdup(), to parallel GC_strdup() and GC_strndup().
>
>This can be easily implemented by the user by GC_size(); GC_malloc(); memcpy() except that I want the new object to be the same kind (normal/atomic etc) as the original. There doesn't seem to be a public API to get the object kind. GC_realloc() does the right thing in this regard.
>
>It's *possible* to get the effect I want from GC_realloc() by building the gc with IGNORE_FREE defined. Unfortunately this also changes the behaviour of free() if REDIRECT_FREE is defined, although this doesn't matter to me.
>
>How would you feel about adding GC_objdup() to the API if I submitted a patch for it?
>
>Bruce
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://napali.hpl.hp.com/pipermail/gc/attachments/20131204/51c18f89/attachment.htm


More information about the Gc mailing list