CVS update: php3/functions

From: Date: Fri, 11 Sep 1998 17:33:44 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-976@lists.php.net to get a copy of this message
Date: Friday September 11, 1998 @ 13:33 Author: ssb Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv12263 Modified Files: oci8.c php3_oci8.h Log Message: fix some memory leaks Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.11 php3/functions/oci8.c:1.12 *** php3/functions/oci8.c:1.11 Fri Sep 11 10:14:39 1998 --- php3/functions/oci8.c Fri Sep 11 13:33:43 1998 *************** *** 27,33 **** +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.11 1998/09/11 14:14:39 ssb Exp $ */ #include "php.h" #include "internal_functions.h" --- 27,33 ---- +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.12 1998/09/11 17:33:43 ssb Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 310,315 **** --- 310,360 ---- /* }}} */ /* {{{ extension-internal functions */ + /* {{{ debug malloc/realloc/free */ + + #if 0 + CONST dvoid *mymalloc(dvoid *ctx, size_t size) + { + dvoid *ret; + oci8_debug("mymalloc(%d)\n", size); + rflush(GLOBAL(php3_rqst)); + ret = (dvoid *)OCI8_MALLOC(size); + return ret; + } + + CONST dvoid *myrealloc(dvoid *ctx, dvoid *ptr, size_t size) + { + dvoid *ret; + oci8_debug("myrealloc(%08x, %d)\n", ptr, size); + rflush(GLOBAL(php3_rqst)); + ret = (dvoid *)OCI8_REALLOC(ptr, size); + return ptr; + } + + CONST void myfree(dvoid *ctx, dvoid *ptr) + { + oci8_debug("myfree(%08x)\n", ptr); + rflush(GLOBAL(php3_rqst)); + OCI8_FREE(ptr); + } + #endif + + /* }}} */ + + static int + oci8_free_column(oci8_out_column *column) + { + if (column->data) { + OCI8_FREE(column->data); + } + if (column->value) { + OCI8_FREE(column->value); + } + return 0; + } + + /* {{{ oci8_free_stmt() */ + static void oci8_free_stmt(oci8_statement *statement) { *************** *** 323,335 **** } if (statement->columns) { _php3_hash_destroy(statement->columns); - } - if (statement->columns) { OCI8_FREE(statement->columns); } OCI8_FREE(statement); } static void oci8_close_conn(oci8_connection *connection) --- 368,384 ---- } if (statement->columns) { _php3_hash_destroy(statement->columns); OCI8_FREE(statement->columns); } + if (statement->binds) { + _php3_hash_destroy(statement->binds); + OCI8_FREE(statement->binds); + } OCI8_FREE(statement); } + /* }}} */ + /* {{{ oci8_close_conn() */ static void oci8_close_conn(oci8_connection *connection) *************** *** 344,349 **** --- 393,400 ---- OCI8_FREE(connection); } + /* }}} */ + /* {{{ oci8_error() */ static ub4 oci8_error(OCIError *err_p, char *what, sword status) *************** *** 383,388 **** --- 434,441 ---- return errcode; } + /* }}} */ + /* {{{ oci8_ping() */ /* test if a connection is still alive and return 1 if it is */ static int oci8_ping(oci8_connection *conn) *************** *** 391,396 **** --- 444,451 ---- return 1; } + /* }}} */ + /* {{{ oci8_debug() */ static void oci8_debug(const char *format,...) { *************** *** 409,442 **** } } } - - #if 0 - CONST dvoid *mymalloc(dvoid *ctx, size_t size) - { - dvoid *ret; - oci8_debug("mymalloc(%d)\n", size); - rflush(GLOBAL(php3_rqst)); - ret = (dvoid *)OCI8_MALLOC(size); - return ret; - } - - CONST dvoid *myrealloc(dvoid *ctx, dvoid *ptr, size_t size) - { - dvoid *ret; - oci8_debug("myrealloc(%08x, %d)\n", ptr, size); - rflush(GLOBAL(php3_rqst)); - ret = (dvoid *)OCI8_REALLOC(ptr, size); - return ptr; - } - - CONST void myfree(dvoid *ctx, dvoid *ptr) - { - oci8_debug("myfree(%08x)\n", ptr); - rflush(GLOBAL(php3_rqst)); - OCI8_FREE(ptr); - } - #endif static oci8_connection * oci8_get_conn(int conn_ind, const char *func, HashTable *list, HashTable *plist) --- 464,472 ---- } } } + /* }}} */ + /* {{{ oci8_get_conn() */ static oci8_connection * oci8_get_conn(int conn_ind, const char *func, HashTable *list, HashTable *plist) *************** *** 453,458 **** --- 483,490 ---- return connection; } + /* }}} */ + /* {{{ oci8_get_stmt() */ static oci8_statement * oci8_get_stmt(int stmt_ind, const char *func, HashTable *list) *************** *** 469,474 **** --- 501,508 ---- return statement; } + /* }}} */ + /* {{{ oci8_get_col() */ static oci8_out_column * oci8_get_col(oci8_statement *statement, int col, char *func) *************** *** 483,488 **** --- 517,524 ---- return outcol; } + /* }}} */ + /* {{{ oci8_make_pval() */ static pval * oci8_make_pval(oci8_out_column *column, char *func) *************** *** 509,517 **** --- 545,556 ---- value->value.str.len = size; value->value.str.val = OCI8_MALLOC(size); memcpy(value->value.str.val, column->data, size); + column->value = value; return value; } + /* }}} */ + /* {{{ oci8_parse() */ static int oci8_parse(oci8_connection *connection, text *query, ub4 len, HashTable *list) *************** *** 538,543 **** --- 577,584 ---- return php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt); } + /* }}} */ + /* {{{ oci8_execute() */ static int oci8_execute(oci8_statement *statement, char *func) *************** *** 559,565 **** statement->columns = OCI8_MALLOC(sizeof(HashTable)); if (!statement->columns || ! _php3_hash_init(statement->columns, 13, NULL, NULL, 0) == FAILURE) { /* out of memory */ return 0; } --- 600,607 ---- statement->columns = OCI8_MALLOC(sizeof(HashTable)); if (!statement->columns || ! _php3_hash_init(statement->columns, 13, NULL, ! (void (*)(void *))oci8_free_column, 0) == FAILURE) { /* out of memory */ return 0; } *************** *** 664,669 **** --- 706,713 ---- return 1; } + /* }}} */ + /* {{{ oci8_fetch() */ static int oci8_fetch(oci8_statement *statement, ub4 nrows, char *func) *************** *** 684,689 **** --- 728,735 ---- return 1; } + /* }}} */ + /* {{{ oci8_bind_in_callback() */ static sb4 oci8_bind_in_callback(dvoid *ictxp, /* context pointer */ *************** *** 740,747 **** return OCI_CONTINUE; } ! /* static sb4 oci8_bind_out_callback */ /* }}} */ /************************* EXTENSION FUNCTIONS *************************/ --- 786,811 ---- return OCI_CONTINUE; } ! /* }}} */ ! /* {{{ oci8_bind_out_callback() */ + static sb4 + oci8_bind_out_callback(dvoid *ctxp, /* context pointer */ + OCIBind *bindp, /* bind handle */ + ub4 iter, /* 0-based execute iteration value */ + ub4 index, /* index of current array for PL/SQL or + row index for SQL */ + dvoid **bufpp, /* pointer to data */ + ub4 **alenpp, /* size after value/piece has been read */ + ub1 *piecep, /* which piece */ + dvoid **indpp, /* indicator value */ + ub2 **rcodepp) /* return code */ + { + return OCI_CONTINUE; + } + + /* }}} */ + /* }}} */ /************************* EXTENSION FUNCTIONS *************************/ *************** *** 1192,1198 **** WRONG_PARAM_COUNT; } convert_to_long(stmt); - convert_to_long(array); statement = oci8_get_stmt(stmt->value.lval, "OCIFetchInto", list); if (statement == NULL) { RETURN_FALSE; --- 1256,1261 ---- *************** *** 1261,1267 **** { pval *stmt, *name, *var; oci8_statement *statement; ! oci8_bind *bind; sword error; if (getParameters(ht, 3, &stmt, &name, &var) == FAILURE) { --- 1324,1330 ---- { pval *stmt, *name, *var; oci8_statement *statement; ! oci8_bind *bind, *tmp_bind; sword error; if (getParameters(ht, 3, &stmt, &name, &var) == FAILURE) { *************** *** 1276,1282 **** } bind = OCI8_CALLOC(1,sizeof(oci8_bind)); if (!bind) { ! RETURN_FALSE; /* out of memory */ } bind->val = var; error = OCIBindByName(statement->pStmt, /* statement handle */ --- 1339,1360 ---- } bind = OCI8_CALLOC(1,sizeof(oci8_bind)); if (!bind) { ! /* out of memory */ ! RETURN_FALSE; ! } ! if (statement->binds == NULL) { ! statement->binds = OCI8_MALLOC(sizeof(HashTable)); ! if (statement->binds == NULL || ! _php3_hash_init(statement->binds, 13, NULL, NULL, 0) == FAILURE) { ! /* out of memory */ ! RETURN_FALSE; ! } ! } ! if (_php3_hash_next_index_insert(statement->binds, bind, ! sizeof(oci8_bind), ! (void **)&tmp_bind) == SUCCESS) { ! OCI8_FREE(bind); ! bind = tmp_bind; } bind->val = var; error = OCIBindByName(statement->pStmt, /* statement handle */ Index: php3/functions/php3_oci8.h diff -c php3/functions/php3_oci8.h:1.8 php3/functions/php3_oci8.h:1.9 *** php3/functions/php3_oci8.h:1.8 Fri Sep 11 10:14:39 1998 --- php3/functions/php3_oci8.h Fri Sep 11 13:33:43 1998 *************** *** 92,97 **** --- 92,98 ---- sb2 indicator; ub2 retcode; ub2 is_opaque; + pval *value; } oci8_out_column; typedef struct { -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#976) next »