CVS update: php3/functions
| From: | ssb | Date: | Thu, 10 Sep 1998 14:51:16 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-903@lists.php.net to get a copy of this message | ||
Date: Thursday September 10, 1998 @ 10:51
Author: ssb
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv25025
Modified Files:
oci8.c php3_oci8.h
Log Message:
purified away that crasher, yeah!
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.6 php3/functions/oci8.c:1.7
*** php3/functions/oci8.c:1.6 Thu Sep 10 07:48:37 1998
--- php3/functions/oci8.c Thu Sep 10 10:51:15 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.6 1998/09/10 11:48:37 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.7 1998/09/10 14:51:15 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 296,303 ****
oci8_debug("Freeing statement handle for \"%s\".", statement->last_query);
OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
OCIHandleFree(statement->pError, OCI_HTYPE_ERROR);
! efree(statement->last_query);
! efree(statement);
}
--- 296,305 ----
oci8_debug("Freeing statement handle for \"%s\".", statement->last_query);
OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
OCIHandleFree(statement->pError, OCI_HTYPE_ERROR);
! OCI8_FREE(statement->last_query);
! _php3_hash_destroy(statement->columns);
! OCI8_FREE(statement->columns);
! OCI8_FREE(statement);
}
***************
*** 311,317 ****
OCILogoff(connection->pServiceContext,
connection->pError));
OCI8_GLOBAL(php3_oci8_module).num_links--;
! efree(connection);
}
--- 313,319 ----
OCILogoff(connection->pServiceContext,
connection->pError));
OCI8_GLOBAL(php3_oci8_module).num_links--;
! OCI8_FREE(connection);
}
***************
*** 380,385 ****
--- 382,414 ----
}
}
+ #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
+
/* }}} */
/************************* EXTENSION FUNCTIONS *************************/
***************
*** 447,463 ****
RETURN_FALSE;
}
! connection = (oci8_connection *)ecalloc(1,sizeof(oci8_connection));
if (connection == NULL) {
RETURN_OUT_OF_MEMORY;
}
! /* Set up the Oracle environment. We can specify our own
! * malloc/realloc/free functions to OCIInitialize, but
! * we don't do that yet.
! */
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
OCIEnvInit(&connection->pEnv, OCI_DEFAULT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&connection->pError,
OCI_HTYPE_ERROR, 0, NULL);
--- 476,493 ----
RETURN_FALSE;
}
! connection = (oci8_connection *)OCI8_CALLOC(1,sizeof(oci8_connection));
if (connection == NULL) {
RETURN_OUT_OF_MEMORY;
}
! /* Set up the Oracle environment. */
! #if 0
! OCIInitialize(OCI_DEFAULT, (dvoid *)connection, mymalloc, myrealloc, myfree);
! #else
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
! #endif
OCIEnvInit(&connection->pEnv, OCI_DEFAULT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&connection->pError,
OCI_HTYPE_ERROR, 0, NULL);
***************
*** 465,475 ****
(dvoid **)&connection->pServiceContext,
OCI_HTYPE_SVCCTX, 0, NULL);
! error = OCILogon(connection->pEnv, connection->pError,
! &connection->pServiceContext,
! username, username_len,
! password, password_len,
! dbname, dbname_len);
if (error) {
oci8_error(connection->pError, "OCILogon", error);
RETURN_FALSE;
--- 495,506 ----
(dvoid **)&connection->pServiceContext,
OCI_HTYPE_SVCCTX, 0, NULL);
! error = OCILogon((OCIEnv *)connection->pEnv,
! (OCIError *)connection->pError,
! (OCISvcCtx **)&connection->pServiceContext,
! (CONST text *)username, (ub4)username_len,
! (CONST text *)password, (ub4)password_len,
! (CONST text *)dbname, (ub4)dbname_len);
if (error) {
oci8_error(connection->pError, "OCILogon", error);
RETURN_FALSE;
***************
*** 541,547 ****
query = arg2->value.str.val;
query_len = arg2->value.str.len;
! statement = ecalloc(1,sizeof(oci8_statement));
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pStmt,
OCI_HTYPE_STMT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
--- 572,578 ----
query = arg2->value.str.val;
query_len = arg2->value.str.len;
! statement = OCI8_CALLOC(1,sizeof(oci8_statement));
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pStmt,
OCI_HTYPE_STMT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
***************
*** 555,561 ****
RETURN_FALSE;
}
! statement->last_query = estrndup(query, query_len);
statement->conn = connection;
RETVAL_LONG(php3_list_insert(statement,
OCI8_GLOBAL(php3_oci8_module).le_stmt));
--- 586,593 ----
RETURN_FALSE;
}
! query[query_len] = '\0';
! statement->last_query = OCI8_STRDUP(query);
statement->conn = connection;
RETVAL_LONG(php3_list_insert(statement,
OCI8_GLOBAL(php3_oci8_module).le_stmt));
***************
*** 595,601 ****
RETURN_FALSE;
}
! statement->columns = emalloc(sizeof(HashTable));
if (!statement->columns ||
_php3_hash_init(statement->columns, 13, NULL, NULL, 0) == FAILURE) {
RETURN_OUT_OF_MEMORY;
--- 627,633 ----
RETURN_FALSE;
}
! statement->columns = OCI8_MALLOC(sizeof(HashTable));
if (!statement->columns ||
_php3_hash_init(statement->columns, 13, NULL, NULL, 0) == FAILURE) {
RETURN_OUT_OF_MEMORY;
***************
*** 608,643 ****
(dvoid *)¶m, counter);
oci8_error(statement->pError, "OCIParamGet", error);
while (error == OCI_SUCCESS) {
! outcol = ecalloc(1,sizeof(oci8_out_column));
if (_php3_hash_index_update(statement->columns, counter, outcol,
sizeof(oci8_out_column), NULL) == FAILURE) {
! efree(outcol->data);
! efree(outcol);
! efree(statement->columns);
RETURN_OUT_OF_MEMORY;
} else {
oci8_debug("added info about column %d", counter);
}
! efree(outcol);
! _php3_hash_index_find(statement->columns, counter, (void **)&outcol);
/* get data type */
/* XXX can get OCI_ATTR_TYPE_NAME instead */
oci8_error(statement->pError, "OCIAttrGet(Parameter,DataType)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->type, (ub4 *)0,
! OCI_ATTR_DATA_TYPE, statement->pError));
/* get data size */
oci8_error(statement->pError, "OCIAttrGet(Parameter,DataSize)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->storage_size, (dvoid *)0,
! OCI_ATTR_DATA_SIZE, statement->pError));
/* get column name */
oci8_error(statement->pError, "OCIAttrGet(Parameter,ColumnName)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid **)&outcol->name,
! (ub4 *)&outcol->name_len,
! (ub4)OCI_ATTR_NAME, statement->pError));
/* Remember the size Oracle told us, we have to increase the
* storage size for some types.
--- 640,680 ----
(dvoid *)¶m, counter);
oci8_error(statement->pError, "OCIParamGet", error);
while (error == OCI_SUCCESS) {
! outcol = OCI8_CALLOC(1,sizeof(oci8_out_column));
if (_php3_hash_index_update(statement->columns, counter, outcol,
sizeof(oci8_out_column), NULL) == FAILURE) {
! OCI8_FREE(outcol);
! OCI8_FREE(statement->columns);
RETURN_OUT_OF_MEMORY;
} else {
oci8_debug("added info about column %d", counter);
}
! OCI8_FREE(outcol);
! if (_php3_hash_index_find(statement->columns, counter,
! (void **)&outcol) == FAILURE ||
! outcol == NULL) {
! php3_error(E_WARNING, "Inserted column lost?!");
! RETURN_FALSE;
! }
! outcol->name = NULL;
/* get data type */
/* XXX can get OCI_ATTR_TYPE_NAME instead */
oci8_error(statement->pError, "OCIAttrGet(Parameter,DataType)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->type, (ub4 *)0,
! OCI_ATTR_DATA_TYPE, statement->pError));
/* get data size */
oci8_error(statement->pError, "OCIAttrGet(Parameter,DataSize)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->storage_size, (dvoid *)0,
! OCI_ATTR_DATA_SIZE, statement->pError));
/* get column name */
oci8_error(statement->pError, "OCIAttrGet(Parameter,ColumnName)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid **)&outcol->name,
! (ub4 *)&outcol->name_len,
! (ub4)OCI_ATTR_NAME, statement->pError));
/* Remember the size Oracle told us, we have to increase the
* storage size for some types.
***************
*** 661,670 ****
outcol->storage_size++; /* add one for string terminator */
break;
}
! outcol->data = (text *)emalloc(outcol->storage_size);
if (outcol->data == NULL) {
! efree(outcol);
! efree(statement->columns);
RETURN_OUT_OF_MEMORY;
}
--- 698,707 ----
outcol->storage_size++; /* add one for string terminator */
break;
}
! outcol->data = (text *)OCI8_MALLOC(outcol->storage_size);
if (outcol->data == NULL) {
! OCI8_FREE(outcol);
! OCI8_FREE(statement->columns);
RETURN_OUT_OF_MEMORY;
}
***************
*** 678,686 ****
if (def_error) {
oci8_error(statement->pError, "OCIDefineByPos", def_error);
! efree(outcol->data);
! efree(outcol);
! efree(statement->columns);
RETURN_FALSE;
}
statement->ncolumns = counter;
--- 715,723 ----
if (def_error) {
oci8_error(statement->pError, "OCIDefineByPos", def_error);
! OCI8_FREE(outcol->data);
! OCI8_FREE(outcol);
! OCI8_FREE(statement->columns);
RETURN_FALSE;
}
statement->ncolumns = counter;
***************
*** 895,901 ****
{
pval *arg1, *arg2;
oci8_statement *statement;
! oci8_out_column *outcol;
int stmt, type, col;
OCI8_TLS_VARS;
--- 932,938 ----
{
pval *arg1, *arg2;
oci8_statement *statement;
! oci8_out_column *outcol = NULL;
int stmt, type, col;
OCI8_TLS_VARS;
***************
*** 916,922 ****
php3_error(E_WARNING, "No such column (%d).", col);
RETURN_FALSE;
}
! RETVAL_STRING(outcol->data,0);
}
/* }}} */
--- 953,959 ----
php3_error(E_WARNING, "No such column (%d).", col);
RETURN_FALSE;
}
! RETVAL_STRING(outcol->data,1);
}
/* }}} */
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.5 php3/functions/php3_oci8.h:1.6
*** php3/functions/php3_oci8.h:1.5 Thu Sep 10 07:47:13 1998
--- php3/functions/php3_oci8.h Thu Sep 10 10:51:16 1998
***************
*** 100,105 ****
--- 100,123 ----
extern php3_module_entry oci8_module_entry;
# define oci8_module_ptr &oci8_module_entry
+ # if 1 /* use system malloc, useful for purify */
+ # define OCI8_MALLOC malloc
+ # define OCI8_CALLOC calloc
+ # define OCI8_REALLOC realloc
+ # define OCI8_FREE free
+ # define OCI8_STRDUP strdup
+ # define OCI8_STRNDUP strndup
+ # else /* use PHP emalloc */
+ # define OCI8_MALLOC emalloc
+ # define OCI8_CALLOC ecalloc
+ # define OCI8_REALLOC erealloc
+ # define OCI8_FREE efree
+ # define OCI8_STRDUP estrdup
+ # define OCI8_STRNDUP estrndup
+ # endif
+
+ # define OCI8_MAX_NAME_LEN 64
+
# define OCI8_CONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_conn)
# define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt)
--
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