-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In php7 the zend_object handler structure is inlined (is no longer a pointer, but rather variable sized depending on various things, so it needs to be at the end of the container class. This is mentioned in the extensive /s upgrading documentation from Zend See "custom objects": https://wiki.php.net/phpng-upgrading In addition I believe that the zend library now takes care of freeing the overall structure, so that shouldn't be done anymore if running php >= 7.0.0.
- Loading branch information
1 parent
041478b
commit 3410796
Showing
2 changed files
with
15 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,14 +331,20 @@ create_cluster_context(zend_class_entry *class_type TSRMLS_DC) { | |
#else | ||
object_properties_init(&cluster->std, class_type); | ||
memcpy(&RedisCluster_handlers, zend_get_std_object_handlers(), sizeof(RedisCluster_handlers)); | ||
RedisCluster_handlers.free_obj = free_cluster_context; | ||
RedisCluster_handlers.offset = XtOffsetOf(redisCluster, std); | ||
RedisCluster_handlers.free_obj = free_cluster_context; | ||
|
||
cluster->std.handlers = &RedisCluster_handlers; | ||
|
||
return &cluster->std; | ||
#endif | ||
} | ||
|
||
/* Helper to retrieve the redisCluster object from the zend_object member */ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
michael-grunder
Author
Member
|
||
static redisCluster *getClusterObject(zend_object *object) { | ||
return (redisCluster*)((char*)(object) - XtOffsetOf(redisCluster, std)); | ||
} | ||
|
||
/* Free redisCluster context */ | ||
void | ||
#if (PHP_MAJOR_VERSION < 7) | ||
|
@@ -347,10 +353,7 @@ free_cluster_context(void *object TSRMLS_DC) | |
free_cluster_context(zend_object *object) | ||
#endif | ||
{ | ||
redisCluster *cluster; | ||
|
||
// Grab context | ||
cluster = (redisCluster*)object; | ||
redisCluster *cluster = getClusterObject(object); | ||
|
||
// Free any allocated prefix, as well as the struct | ||
if(cluster->flags->prefix) efree(cluster->flags->prefix); | ||
|
@@ -366,8 +369,11 @@ free_cluster_context(zend_object *object) | |
|
||
if(cluster->err) efree(cluster->err); | ||
|
||
// Finally, free the redisCluster structure itself | ||
zend_object_std_dtor(&cluster->std TSRMLS_CC); | ||
|
||
#if (PHP_MAJOR_VERSION < 7) | ||
efree(cluster); | ||
#endif | ||
} | ||
|
||
/* Attempt to connect to a Redis cluster provided seeds and timeout options */ | ||
|
We don't need this helper because we have GET_CONTEXT macro which does the same work