X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqlob.c;h=5d1f6ba7e00b5328a1504beeb01a7bcae7ce1754;hp=1c6e7b71bd499f7e7cb96aa27e548873f9acc99a;hb=8897b5a581a86279a2ee371784b6b7670c8b8cc1;hpb=10e7d6adccdd55554f1512de5e829a75aef62461 diff --git a/src/php_pqlob.c b/src/php_pqlob.c index 1c6e7b7..5d1f6ba 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -28,11 +28,11 @@ zend_class_entry *php_pqlob_class_entry; static zend_object_handlers php_pqlob_object_handlers; static HashTable php_pqlob_object_prophandlers; -static void php_pqlob_object_free(void *o TSRMLS_DC) +static void php_pqlob_object_free(zend_object *o) { - php_pqlob_object_t *obj = o; + php_pqlob_object_t *obj = PHP_PQ_OBJ(NULL, o); #if DBG_GC - fprintf(stderr, "FREE lob(#%d) %p (txn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->txn->zv.handle, obj->intern->txn); + fprintf(stderr, "FREE lob(#%d) %p (txn(#%d): %p)\n", obj->zo.handle, obj, obj->intern->txn->zo.handle, obj->intern->txn); #endif if (obj->intern) { if (obj->intern->lofd) { @@ -40,77 +40,67 @@ static void php_pqlob_object_free(void *o TSRMLS_DC) } /* invalidate the stream */ if (obj->intern->stream) { - zend_list_delete(obj->intern->stream); - obj->intern->stream = 0; + zend_list_delete(obj->intern->stream->res); + obj->intern->stream = NULL; } - php_pq_object_delref(obj->intern->txn TSRMLS_CC); + php_pq_object_delref(obj->intern->txn); efree(obj->intern); obj->intern = NULL; } - zend_object_std_dtor((zend_object *) o TSRMLS_CC); - efree(obj); + php_pq_object_dtor(o); } -zend_object_value php_pqlob_create_object_ex(zend_class_entry *ce, php_pqlob_t *intern, php_pqlob_object_t **ptr TSRMLS_DC) +php_pqlob_object_t *php_pqlob_create_object_ex(zend_class_entry *ce, php_pqlob_t *intern) { - php_pqlob_object_t *o; - - o = ecalloc(1, sizeof(*o)); - zend_object_std_init((zend_object *) o, ce TSRMLS_CC); - object_properties_init((zend_object *) o, ce); - o->prophandler = &php_pqlob_object_prophandlers; - - if (ptr) { - *ptr = o; - } - - if (intern) { - o->intern = intern; - } - - o->zv.handle = zend_objects_store_put((zend_object *) o, NULL, php_pqlob_object_free, NULL TSRMLS_CC); - o->zv.handlers = &php_pqlob_object_handlers; + return php_pq_object_create(ce, intern, sizeof(php_pqlob_object_t), + &php_pqlob_object_handlers, &php_pqlob_object_prophandlers); +} - return o->zv; +static zend_object *php_pqlob_create_object(zend_class_entry *class_type) +{ + return &php_pqlob_create_object_ex(class_type, NULL)->zo; } -static zend_object_value php_pqlob_create_object(zend_class_entry *class_type TSRMLS_DC) +static void php_pqlob_object_read_transaction(zval *object, void *o, zval *return_value) { - return php_pqlob_create_object_ex(class_type, NULL, NULL TSRMLS_CC); + php_pqlob_object_t *obj = o; + + php_pq_object_to_zval(obj->intern->txn, return_value); } -static void php_pqlob_object_read_transaction(zval *object, void *o, zval *return_value TSRMLS_DC) +static void php_pqlob_object_gc_transaction(zval *object, void *o, zval *return_value) { php_pqlob_object_t *obj = o; + zval ztxn; - php_pq_object_to_zval(obj->intern->txn, &return_value TSRMLS_CC); + php_pq_object_to_zval_no_addref(obj->intern->txn, &ztxn); + add_next_index_zval(return_value, &ztxn); } -static void php_pqlob_object_read_oid(zval *object, void *o, zval *return_value TSRMLS_DC) +static void php_pqlob_object_read_oid(zval *object, void *o, zval *return_value) { php_pqlob_object_t *obj = o; RETVAL_LONG(obj->intern->loid); } -static void php_pqlob_object_update_stream(zval *this_ptr, php_pqlob_object_t *obj, zval **zstream TSRMLS_DC); +static void php_pqlob_object_update_stream(zval *this_ptr, php_pqlob_object_t *obj, zval *zstream); -static void php_pqlob_object_read_stream(zval *object, void *o, zval *return_value TSRMLS_DC) +static void php_pqlob_object_read_stream(zval *object, void *o, zval *return_value) { php_pqlob_object_t *obj = o; + zval zstream; if (!obj->intern->stream) { - zval *zstream; - - php_pqlob_object_update_stream(object, obj, &zstream TSRMLS_CC); - RETVAL_ZVAL(zstream, 1, 1); + php_pqlob_object_update_stream(object, obj, &zstream); } else { - RETVAL_RESOURCE(obj->intern->stream); - zend_list_addref(obj->intern->stream); + php_stream_to_zval(obj->intern->stream, &zstream); } + + RETVAL_ZVAL(&zstream, 1, 0); } -static size_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length TSRMLS_DC) +static size_t php_pqlob_stream_write(php_stream *stream, const char *buffer, size_t length) { php_pqlob_object_t *obj = stream->abstract; int written = 0; @@ -119,16 +109,16 @@ static size_t php_pqlob_stream_write(php_stream *stream, const char *buffer, siz written = lo_write(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, buffer, length); if (written < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write to LOB with oid=%u (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + php_error_docref(NULL, E_WARNING, "Failed to write to LOB with oid=%u (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } return written; } -static size_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length TSRMLS_DC) +static size_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t length) { php_pqlob_object_t *obj = stream->abstract; int read = 0; @@ -143,27 +133,27 @@ static size_t php_pqlob_stream_read(php_stream *stream, char *buffer, size_t len read = lo_read(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, buffer, length); if (read < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read from LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + php_error_docref(NULL, E_WARNING, "Failed to read from LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } return read; } -static ZEND_RESULT_CODE php_pqlob_stream_close(php_stream *stream, int close_handle TSRMLS_DC) +static ZEND_RESULT_CODE php_pqlob_stream_close(php_stream *stream, int close_handle) { return SUCCESS; } -static int php_pqlob_stream_flush(php_stream *stream TSRMLS_DC) +static int php_pqlob_stream_flush(php_stream *stream) { return SUCCESS; } -static ZEND_RESULT_CODE php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) +static ZEND_RESULT_CODE php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset) { ZEND_RESULT_CODE rv = FAILURE; php_pqlob_object_t *obj = stream->abstract; @@ -172,14 +162,14 @@ static ZEND_RESULT_CODE php_pqlob_stream_seek(php_stream *stream, off_t offset, int position = lo_lseek(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, offset, whence); if (position < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + php_error_docref(NULL, E_WARNING, "Failed to seek offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); rv = FAILURE; } else { *newoffset = position; rv = SUCCESS; } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } return rv; @@ -201,30 +191,21 @@ static php_stream_ops php_pqlob_stream_ops = { NULL, /* set_option */ }; -static void php_pqlob_object_update_stream(zval *this_ptr, php_pqlob_object_t *obj, zval **zstream_ptr TSRMLS_DC) +static void php_pqlob_object_update_stream(zval *zpqlob, php_pqlob_object_t *obj, zval *zstream) { - zval *zstream, zmember; - php_stream *stream; + zval zmember; - INIT_PZVAL(&zmember); - ZVAL_STRINGL(&zmember, "stream", sizeof("stream")-1, 0); + ZVAL_STRINGL(&zmember, "stream", sizeof("stream")-1); - MAKE_STD_ZVAL(zstream); if (!obj) { - obj = zend_object_store_get_object(getThis() TSRMLS_CC); + obj = PHP_PQ_OBJ(zpqlob, NULL); } - stream = php_stream_alloc(&php_pqlob_stream_ops, obj, NULL, "r+b"); - stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE; - zend_list_addref(obj->intern->stream = stream->rsrc_id); - php_stream_to_zval(stream, zstream); - - zend_get_std_object_handlers()->write_property(getThis(), &zmember, zstream, NULL TSRMLS_CC); + obj->intern->stream = php_stream_alloc(&php_pqlob_stream_ops, obj, NULL, "r+b"); + obj->intern->stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE; + php_stream_to_zval(obj->intern->stream, zstream); - if (zstream_ptr) { - *zstream_ptr = zstream; - } else { - zval_ptr_dtor(&zstream); - } + zend_get_std_object_handlers()->write_property(zpqlob, &zmember, zstream, NULL); + zval_ptr_dtor(&zmember); } ZEND_BEGIN_ARG_INFO_EX(ai_pqlob_construct, 0, 0, 1) @@ -235,45 +216,45 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(pqlob, __construct) { zend_error_handling zeh; zval *ztxn; - long mode = INV_WRITE|INV_READ, loid = InvalidOid; + zend_long mode = INV_WRITE|INV_READ, loid = InvalidOid; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &ztxn, php_pqtxn_class_entry, &loid, &mode); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "O|ll", &ztxn, php_pqtxn_class_entry, &loid, &mode); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - php_pqtxn_object_t *txn_obj = zend_object_store_get_object(ztxn TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); + php_pqtxn_object_t *txn_obj = PHP_PQ_OBJ(ztxn, NULL); if (obj->intern) { - throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\LOB already initialized"); + throw_exce(EX_BAD_METHODCALL, "pq\\LOB already initialized"); } else if (!txn_obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transaction not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\Transaction not initialized"); } else if (!txn_obj->intern->open) { - throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transation already closed"); + throw_exce(EX_RUNTIME, "pq\\Transation already closed"); } else { if (loid == InvalidOid) { loid = lo_creat(txn_obj->intern->conn->intern->conn, mode); } if (loid == InvalidOid) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to create large object with mode '%s' (%s)", php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn)); } else { int lofd = lo_open(txn_obj->intern->conn->intern->conn, loid, mode); if (lofd < 0) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn)); } else { obj->intern = ecalloc(1, sizeof(*obj->intern)); obj->intern->lofd = lofd; obj->intern->loid = loid; - php_pq_object_addref(txn_obj TSRMLS_CC); + php_pq_object_addref(txn_obj); obj->intern->txn = txn_obj; } } - php_pqconn_notify_listeners(txn_obj->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(txn_obj->intern->conn); } } } @@ -284,28 +265,28 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(pqlob, write) { zend_error_handling zeh; char *data_str; - int data_len; + size_t data_len; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &data_str, &data_len); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); if (!obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\LOB not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\LOB not initialized"); } else { int written = lo_write(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, data_str, data_len); if (written < 0) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to write to LOB with oid=%u (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to write to LOB with oid=%u (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } else { RETVAL_LONG(written); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } } } @@ -316,36 +297,37 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqlob_read, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqlob, read) { zend_error_handling zeh; - long length = 0x1000; + zend_long length = 0x1000; zval *zread = NULL; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lz!", &length, &zread); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|lz!", &length, &zread); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); if (!obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\LOB not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\LOB not initialized"); } else { - char *buffer = emalloc(length + 1); - int read = lo_read(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, buffer, length); + zend_string *buffer = zend_string_alloc(length, 0); + int read = lo_read(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, &buffer->val[0], length); if (read < 0) { - efree(buffer); - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to read from LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + zend_string_release(buffer); + throw_exce(EX_RUNTIME, "Failed to read from LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } else { if (zread) { + ZVAL_DEREF(zread); zval_dtor(zread); ZVAL_LONG(zread, read); } - buffer[read] = '\0'; - RETVAL_STRINGL(buffer, read, 0); + buffer->val[buffer->len = read] = '\0'; + RETVAL_STR(buffer); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } } } @@ -356,28 +338,28 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqlob_seek, 0, 0, 1) ZEND_END_ARG_INFO(); static PHP_METHOD(pqlob, seek) { zend_error_handling zeh; - long offset, whence = SEEK_SET; + zend_long offset, whence = SEEK_SET; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &offset, &whence); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &offset, &whence); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); if (!obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\LOB not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\LOB not initialized"); } else { int position = lo_lseek(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, offset, whence); if (position < 0) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to seek offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to seek offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } else { RETVAL_LONG(position); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } } } @@ -388,25 +370,25 @@ static PHP_METHOD(pqlob, tell) { zend_error_handling zeh; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); rv = zend_parse_parameters_none(); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); if (!obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\LOB not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\LOB not initialized"); } else { int position = lo_tell(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd); if (position < 0) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to tell offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to tell offset in LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } else { RETVAL_LONG(position); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } } } @@ -416,32 +398,32 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqlob_truncate, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqlob, truncate) { zend_error_handling zeh; - long length = 0; + zend_long length = 0; ZEND_RESULT_CODE rv; - zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &length); - zend_restore_error_handling(&zeh TSRMLS_CC); + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh); + rv = zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &length); + zend_restore_error_handling(&zeh); if (SUCCESS == rv) { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); + php_pqlob_object_t *obj = PHP_PQ_OBJ(getThis(), NULL); if (!obj->intern) { - throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\LOB not initialized"); + throw_exce(EX_UNINITIALIZED, "pq\\LOB not initialized"); } else { int rc = lo_truncate(obj->intern->txn->intern->conn->intern->conn, obj->intern->lofd, length); if (rc != 0) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to truncate LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); + throw_exce(EX_RUNTIME, "Failed to truncate LOB with oid=%d (%s)", obj->intern->loid, PHP_PQerrorMessage(obj->intern->txn->intern->conn->intern->conn)); } - php_pqconn_notify_listeners(obj->intern->txn->intern->conn TSRMLS_CC); + php_pqconn_notify_listeners(obj->intern->txn->intern->conn); } } } static zend_function_entry php_pqlob_methods[] = { - PHP_ME(pqlob, __construct, ai_pqlob_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(pqlob, __construct, ai_pqlob_construct, ZEND_ACC_PUBLIC) PHP_ME(pqlob, write, ai_pqlob_write, ZEND_ACC_PUBLIC) PHP_ME(pqlob, read, ai_pqlob_read, ZEND_ACC_PUBLIC) PHP_ME(pqlob, seek, ai_pqlob_seek, ZEND_ACC_PUBLIC) @@ -462,36 +444,40 @@ PHP_MINIT_FUNCTION(pqlob) php_pq_object_prophandler_t ph = {0}; INIT_NS_CLASS_ENTRY(ce, "pq", "LOB", php_pqlob_methods); - php_pqlob_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); + php_pqlob_class_entry = zend_register_internal_class_ex(&ce, NULL); php_pqlob_class_entry->create_object = php_pqlob_create_object; memcpy(&php_pqlob_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + php_pqlob_object_handlers.offset = XtOffsetOf(php_pqlob_object_t, zo); + php_pqlob_object_handlers.free_obj = php_pqlob_object_free; php_pqlob_object_handlers.read_property = php_pq_object_read_prop; php_pqlob_object_handlers.write_property = php_pq_object_write_prop; php_pqlob_object_handlers.clone_obj = NULL; php_pqlob_object_handlers.get_property_ptr_ptr = NULL; - php_pqlob_object_handlers.get_gc = NULL; + php_pqlob_object_handlers.get_gc = php_pq_object_get_gc; php_pqlob_object_handlers.get_properties = php_pq_object_properties; php_pqlob_object_handlers.get_debug_info = php_pq_object_debug_info; - zend_hash_init(&php_pqlob_object_prophandlers, 3, NULL, NULL, 1); + zend_hash_init(&php_pqlob_object_prophandlers, 3, NULL, php_pq_object_prophandler_dtor, 1); - zend_declare_property_null(php_pqlob_class_entry, ZEND_STRL("transaction"), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_null(php_pqlob_class_entry, ZEND_STRL("transaction"), ZEND_ACC_PUBLIC); ph.read = php_pqlob_object_read_transaction; - zend_hash_add(&php_pqlob_object_prophandlers, "transaction", sizeof("transaction"), (void *) &ph, sizeof(ph), NULL); + ph.gc = php_pqlob_object_gc_transaction; + zend_hash_str_add_mem(&php_pqlob_object_prophandlers, "transaction", sizeof("transaction")-1, (void *) &ph, sizeof(ph)); + ph.gc = NULL; - zend_declare_property_long(php_pqlob_class_entry, ZEND_STRL("oid"), InvalidOid, ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_long(php_pqlob_class_entry, ZEND_STRL("oid"), InvalidOid, ZEND_ACC_PUBLIC); ph.read = php_pqlob_object_read_oid; - zend_hash_add(&php_pqlob_object_prophandlers, "oid", sizeof("oid"), (void *) &ph, sizeof(ph), NULL); + zend_hash_str_add_mem(&php_pqlob_object_prophandlers, "oid", sizeof("oid")-1, (void *) &ph, sizeof(ph)); - zend_declare_property_null(php_pqlob_class_entry, ZEND_STRL("stream"), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_null(php_pqlob_class_entry, ZEND_STRL("stream"), ZEND_ACC_PUBLIC); ph.read = php_pqlob_object_read_stream; - zend_hash_add(&php_pqlob_object_prophandlers, "stream", sizeof("stream"), (void *) &ph, sizeof(ph), NULL); + zend_hash_str_add_mem(&php_pqlob_object_prophandlers, "stream", sizeof("stream")-1, (void *) &ph, sizeof(ph)); - zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("INVALID_OID"), InvalidOid TSRMLS_CC); - zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("R"), INV_READ TSRMLS_CC); - zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("W"), INV_WRITE TSRMLS_CC); - zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("RW"), INV_READ|INV_WRITE TSRMLS_CC); + zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("INVALID_OID"), InvalidOid); + zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("R"), INV_READ); + zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("W"), INV_WRITE); + zend_declare_class_constant_long(php_pqlob_class_entry, ZEND_STRL("RW"), INV_READ|INV_WRITE); return SUCCESS; }