flux-core icon indicating copy to clipboard operation
flux-core copied to clipboard

libutil: add destruction wrapper functions

Open chu11 opened this issue 2 years ago • 1 comments

to avoid compiler warnings I've made a number of:

/* zhashx_destructor_fn */                                                                                                                  
static void json_decref_wrapper (void **arg)                                                                                                
{                                                                                                                                           
    json_t **o = arg;                                                                                                                       
    json_decref (*o);                                                                                                                       
}     

funtions scattered around flux. It might be nice to stick em somewhere common so we don't have to keep on re-defining them. I'm sure there's more of them out there, but I always use the "_wrapper" suffix, not sure what other suffixes others used.

Bonus points: write a macro to auto-do this, like JSON_DECREF_ZHASH_DESTROY or something???

chu11 avatar Jul 29 '22 17:07 chu11

Suggest not using the json_ prefix because then it's hard to tell what's part of jansson and what's not when perusing the code.

Since this is the zeromq destructor footprint maybe we could start a zutil_ class in libzmqutil. (e.g. zutil_json_destructor() or similar.

garlick avatar Jul 29 '22 17:07 garlick