Skip to content

Instantly share code, notes, and snippets.

@Sean-Der
Created April 15, 2015 18:08
Show Gist options
  • Save Sean-Der/5cd42ee123336264332b to your computer and use it in GitHub Desktop.
Save Sean-Der/5cd42ee123336264332b to your computer and use it in GitHub Desktop.
When unpacking we currently use one zval *
https://github.com/msgpack/msgpack-php/blob/master/msgpack/unpack_template.h#L119
This worked great when we change that pointer's value, and malloc a zval
https://github.com/msgpack/msgpack-php/blob/master/msgpack_unpack.c#L31
https://github.com/msgpack/msgpack-php/blob/master/msgpack_unpack.c#L40
However, now the zend-api expects to use stack allocated zvals right? I
don't want to edit unpack_template.h, but I don't see an easy way to
reallocate for every object (something like alloca) I can create one
zval on the stack, but then a pointer to that is passed to all the
serialization functions.
What would be the right way to do this? On my branch I just pulled the
ALLOC_INIT_ZVAL so it segfaults
https://github.com/Sean-Der/msgpack-php/blob/php7-support/msgpack_unpack.c#L25
It works great (and leaks memory) if I emalloc where we used to ALLOC_INIT_ZVAL,
but currently that is the only way I can think to do it?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment