Skip to content

Commit

Permalink
Introduce ByteBuffer class
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Aug 1, 2022
1 parent 439ab1b commit 5c0442a
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 95 deletions.
26 changes: 26 additions & 0 deletions ZendUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef HAVE_BITARRAY_ZEND_UTIL_CPP_H
#define HAVE_BITARRAY_ZEND_UTIL_CPP_H

extern "C" {
#include "php.h"
}

template<typename class_name>
static inline class_name * fetch_from_zend_object(zend_object *obj) {
return (class_name *)((char *)obj - XtOffsetOf(class_name, std));
}

template<typename class_name>
static class_name* alloc_custom_zend_object(zend_class_entry* ce, zend_object_handlers *handlers) {
class_name* object = (class_name*)emalloc(sizeof(class_name) + zend_object_properties_size(ce));

zend_object_std_init(&object->std, ce);
object_properties_init(&object->std, ce);

object->std.handlers = handlers;

return object;
}

#endif

Loading

0 comments on commit 5c0442a

Please sign in to comment.