svn: /pecl/amqp/trunk/ amqp_envelope.c amqp_queue.c
| From: | Pieter de Zwart | Date: | Wed, 07 Dec 2011 23:09:59 +0000 |
| Subject: | svn: /pecl/amqp/trunk/ amqp_envelope.c amqp_queue.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-17322@lists.php.net to get a copy of this message | ||
pdezwart Wed, 07 Dec 2011 23:09:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=320618
Log:
* Fixing memory leaks in consume.
* Cleaning up unused variables
* Fixing memory leaks in envelope var_dump
Changed paths:
U pecl/amqp/trunk/amqp_envelope.c
U pecl/amqp/trunk/amqp_queue.c
Modified: pecl/amqp/trunk/amqp_envelope.c
===================================================================
--- pecl/amqp/trunk/amqp_envelope.c 2011-12-07 22:04:49 UTC (rev 320617)
+++ pecl/amqp/trunk/amqp_envelope.c 2011-12-07 23:09:59 UTC (rev 320618)
@@ -49,7 +49,6 @@
/* Get the envelope object from which to read */
amqp_envelope_object *envelope = (amqp_envelope_object *)zend_object_store_get_object(object
TSRMLS_CC);
- ALLOC_HASHTABLE(retval);
/* Keep the # 18 matching the number of entries in this table*/
ZEND_INIT_SYMTABLE_EX(retval, 18 + 1, 0);
@@ -122,10 +121,8 @@
ZVAL_STRINGL(value, envelope->correlation_id, strlen(envelope->correlation_id), 1);
zend_hash_add(retval, "correlation_id", strlen("correlation_id") + 1,
&value, sizeof(zval *), NULL);
- MAKE_STD_ZVAL(value);
zend_hash_add(retval, "headers", strlen("headers") + 1, envelope->headers,
sizeof(envelope->headers), NULL);
- Z_ADDREF_P(envelope->headers);
-
+
return retval;
}
#endif
@@ -138,6 +135,8 @@
zval_ptr_dtor(&envelope->headers);
}
+ efree(envelope->body);
+
zend_object_std_dtor(&envelope->zo TSRMLS_CC);
efree(object);
Modified: pecl/amqp/trunk/amqp_queue.c
===================================================================
--- pecl/amqp/trunk/amqp_queue.c 2011-12-07 22:04:49 UTC (rev 320617)
+++ pecl/amqp/trunk/amqp_queue.c 2011-12-07 23:09:59 UTC (rev 320618)
@@ -214,7 +214,6 @@
}
if (p->_flags & AMQP_BASIC_HEADERS_FLAG) {
- zval *headers;
int i;
for (i = 0; i < p->headers.num_entries; i++) {
@@ -720,13 +719,8 @@
amqp_channel_object *channel;
amqp_connection_object *connection;
- amqp_rpc_reply_t res;
long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
-
- char *pbuf;
- int buf_max = FRAME_MAX;
-
/* Parse out the method parameters */
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &id,
amqp_queue_class_entry, &flags) == FAILURE) {
return;
@@ -763,7 +757,7 @@
s.no_ack = (AMQP_AUTOACK & flags) ? 1 : 0;
/* Get the next message using basic.get */
- int status = amqp_send_method(
+ amqp_send_method(
connection->connection_resource->connection_state,
channel->channel_id,
AMQP_BASIC_GET_METHOD,
@@ -803,30 +797,14 @@
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
- zval *retval_ptr = NULL;
int function_call_succeeded = 1;
int read;
- char str[256];
- char **pstr = (char **)&str;
long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
- amqp_basic_get_ok_t *get_ok;
- amqp_channel_close_t *err;
-
- int result;
-
- amqp_frame_t frame;
-
- size_t len = 0;
- char *tmp = NULL;
- char *old_tmp = NULL;
-
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Of|l", &id,
amqp_queue_class_entry, &fci, &fci_cache, &flags) == FAILURE) {
return;
}
- /* Initialize the return value pointer */
- fci.retval_ptr_ptr = &retval_ptr;
/* Pull the queue out */
queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);
@@ -857,13 +835,16 @@
/* Initialize the message */
zval *message;
MAKE_STD_ZVAL(message);
- array_init(message);
-
+
/* Read the message */
read = read_message_from_channel(connection->connection_resource->connection_state,
message);
/* Make the callback */
if (read == AMQP_READ_SUCCESS) {
+ /* Initialize the return value pointer */
+ zval *retval_ptr = NULL;
+ fci.retval_ptr_ptr = &retval_ptr;
+
/* Build the parameter array */
zval *params;
MAKE_STD_ZVAL(params);
@@ -877,7 +858,7 @@
/* Convert everything to be callable */
zend_fcall_info_args(&fci, params TSRMLS_CC);
-
+
/* Call the function, and track the return value */
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS &&
fci.retval_ptr_ptr && *fci.retval_ptr_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr);
@@ -890,6 +871,7 @@
/* Clean up our mess */
zend_fcall_info_args_clear(&fci, 1);
+ zval_ptr_dtor(¶ms);
}
} while (read != AMQP_READ_ERROR && function_call_succeeded == 1);