Skip to content

Commit

Permalink
Refactor pdo_sqlite (only compilable)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Apr 23, 2014
1 parent bd9f575 commit a30442c
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 115 deletions.
2 changes: 1 addition & 1 deletion ext/pdo/pdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ PDO_API int php_pdo_register_driver(pdo_driver_t *driver)
return FAILURE; /* NOTREACHED */
}

return zend_hash_str_add_mem(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len, (void**)&driver, sizeof(pdo_driver_t *)) != NULL;
return zend_hash_str_add_ptr(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len, driver) != NULL;
}

PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver)
Expand Down
5 changes: 4 additions & 1 deletion ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ static PHP_METHOD(PDO, dbh_constructor)
zval *options = NULL;
char alt_dsn[512];
int call_factory = 1;
char tmp;

if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!a!", &data_source, &data_source_len,
&username, &usernamelen, &password, &passwordlen, &options)) {
Expand Down Expand Up @@ -254,8 +255,10 @@ static PHP_METHOD(PDO, dbh_constructor)
}
}

tmp = data_source[colon - data_source];
data_source[colon - data_source] = '\0';
driver = pdo_find_driver(data_source, colon - data_source);

data_source[colon - data_source] = tmp;
if (!driver) {
/* NB: don't want to include the data_source in the error message as
* it might contain a password */
Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/php_pdo_sqlite_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct pdo_sqlite_fci {
struct pdo_sqlite_func {
struct pdo_sqlite_func *next;

zval *func, *step, *fini;
zval func, step, fini;
int argc;
const char *funcname;

Expand All @@ -50,7 +50,7 @@ struct pdo_sqlite_collation {
struct pdo_sqlite_collation *next;

const char *name;
zval *callback;
zval callback;
struct pdo_sqlite_fci fc;
};

Expand Down
Loading

0 comments on commit a30442c

Please sign in to comment.