diff --git a/README.md b/README.md index fb35a47..fba0bd1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ Method names and functionalities are inspired by [Kotlin.Collections](https://ko ### 1.1 Notes * Requires PHP 7.1 and above. -* Currently not working on MacOS. Fix in progress. ## 2. Documentation diff --git a/src/collections.c b/src/collections.c index 8e33721..0c00a03 100644 --- a/src/collections.c +++ b/src/collections.c @@ -14,7 +14,7 @@ #include "php_collections.h" -zend_object_handlers* collection_handlers; +zend_object_handlers collection_handlers; zend_class_entry* collections_collection_ce; zend_class_entry* collections_pair_ce; @@ -36,13 +36,12 @@ PHP_MINIT_FUNCTION(collections) 2, zend_ce_countable, #endif zend_ce_arrayaccess); - collection_handlers = (zend_object_handlers*)emalloc(sizeof(zend_object_handlers)); - memcpy(collection_handlers, &std_object_handlers, sizeof(zend_object_handlers)); - collection_handlers->count_elements = count_collection; - collection_handlers->unset_dimension = collection_offset_unset; - collection_handlers->write_dimension = collection_offset_set; - collection_handlers->read_dimension = collection_offset_get; - collection_handlers->has_dimension = collection_offset_exists; + memcpy(&collection_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + collection_handlers.count_elements = count_collection; + collection_handlers.unset_dimension = collection_offset_unset; + collection_handlers.write_dimension = collection_offset_set; + collection_handlers.read_dimension = collection_offset_get; + collection_handlers.has_dimension = collection_offset_exists; zend_class_entry pair_ce; INIT_CLASS_ENTRY_EX(pair_ce, "Pair", sizeof "Pair" - 1, pair_methods); collections_pair_ce = zend_register_internal_class(&pair_ce); diff --git a/src/collections_methods.c b/src/collections_methods.c index cc98a33..2f1b520 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -15,7 +15,7 @@ zend_object_std_init(name, ce); \ (name)->handlers = object_handlers #define NEW_COLLECTION_OBJ(name) \ - NEW_OBJ(name, collections_collection_ce, collection_handlers) + NEW_OBJ(name, collections_collection_ce, &collection_handlers) #define NEW_PAIR_OBJ(name) \ NEW_OBJ(name, collections_pair_ce, &std_object_handlers); \ name->properties = (zend_array*)emalloc(sizeof(zend_array)); \ diff --git a/src/php_collections.h b/src/php_collections.h index 9bf89b5..a5d4bdc 100644 --- a/src/php_collections.h +++ b/src/php_collections.h @@ -31,7 +31,7 @@ extern PHP_COLLECTIONS_API zend_class_entry* collections_pair_ce; extern zend_string* collections_pair_first; extern zend_string* collections_pair_second; -extern zend_object_handlers* collection_handlers; +extern zend_object_handlers collection_handlers; int count_collection(zval* obj, zend_long* count); int collection_offset_exists(zval* object, zval* offset, int check_empty);