node-addon-layer icon indicating copy to clipboard operation
node-addon-layer copied to clipboard

shim_unpack() should allocate shim_val_t for you

Open jclulow opened this issue 10 years ago • 0 comments

It would be neat if this was the pattern, instead of what exists today:

int
myaddon_myfunc(shim_ctx_t *ctx, shim_args_t *args)
{
        shim_val_t *string0, *string1;

        if (!shim_unpack(ctx, args,
            SHIM_TYPE_STRING, &string0,
            SHIM_TYPE_STRING, &string1,
            SHIM_TYPE_UNKNOWN)) {
                return (FALSE);
        }

        /* Do stuff with string0 and string1 ... */

        shim_value_release(string0);
        shim_value_release(string1);

        return (TRUE);
}

Specifically: shim_unpack() should either:

  • succeed and allocate all of the required shim_val_ts
  • fail and allocate none of them (i.e. free any that it got part way through allocating prior to failure)

jclulow avatar Oct 10 '13 23:10 jclulow