Skip to content

Commit

Permalink
Merge branch 'create_path_buffer' of https://github.com/lreese/php-zo…
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiz committed Apr 4, 2012
2 parents 2459d97 + 2d4b7bd commit 27c0593
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
22 changes: 17 additions & 5 deletions package.xml
Expand Up @@ -15,9 +15,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
<email>andrei@php.net</email>
<active>yes</active>
</lead>
<date>2012-01-12</date>
<date>2012-01-13</date>
<version>
<release>0.2.0</release>
<release>0.2.1</release>
<api>0.2.0</api>
</version>
<stability>
Expand All @@ -26,9 +26,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- Added session handler support
- Added connect() and delete methods
- Bug fixes
- Package up missed source files
</notes>
<contents>
<dir name="/">
Expand All @@ -40,6 +38,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file role='src' name='config.m4'/>
<file role='src' name='php_zookeeper.c'/>
<file role='src' name='php_zookeeper.h'/>
<file role='src' name='php_zookeeper_private.h'/>
<file role='src' name='php_zookeeper_session.c'/>
<file role='src' name='php_zookeeper_session.h'/>
<file role='src' name='zoo_lock.c'/>
<file role='src' name='zoo_lock.h'/>
</dir> <!-- / -->
</contents>
<dependencies>
Expand All @@ -57,6 +60,15 @@ http://pear.php.net/dtd/package-2.0.xsd">
<providesextension>zookeeper</providesextension>
<extsrcrelease/>
<changelog>
<release>
<stability><release>beta</release><api>beta</api></stability>
<version><release>0.2.1</release><api>0.2.0</api></version>
<date>2012-01-13</date>
<notes>
- Package up missed source files
</notes>
</release>

<release>
<stability><release>beta</release><api>beta</api></stability>
<version><release>0.2.0</release><api>0.2.0</api></version>
Expand Down
14 changes: 11 additions & 3 deletions php_zookeeper.c
Expand Up @@ -189,8 +189,8 @@ static PHP_METHOD(Zookeeper, create)
int path_len, value_len;
zval *acl_info = NULL;
long flags = 0;
char realpath[256];
int realpath_max = 256;
char *realpath;
int realpath_max = 0;
struct ACL_vector aclv = { 0, };
int status = ZOK;
ZK_METHOD_INIT_VARS;
Expand All @@ -202,15 +202,23 @@ static PHP_METHOD(Zookeeper, create)

ZK_METHOD_FETCH_OBJECT;

realpath_max = path_len + 1;
if (flags & ZOO_SEQUENCE) {
// allocate extra space for sequence numbers
realpath_max += 11;
}
realpath = emalloc(realpath_max);

php_parse_acl_list(acl_info, &aclv);
status = zoo_create(i_obj->zk, path, value, value_len, (acl_info ? &aclv : 0), flags,
realpath, realpath_max);
if (status != ZOK) {
efree(realpath);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "error: %s", zerror(status));
return;
}

RETURN_STRING(realpath, 1);
RETURN_STRING(realpath, 0);
}
/* }}} */

Expand Down

0 comments on commit 27c0593

Please sign in to comment.