diff options
Diffstat (limited to 'database/sqlite/sqlite.c')
| -rw-r--r-- | database/sqlite/sqlite.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c index 9148616..5faa0b7 100644 --- a/database/sqlite/sqlite.c +++ b/database/sqlite/sqlite.c @@ -108,8 +108,7 @@ static int _cb_parse_result(void *NotUsed, int argc, char **argv, char **colName // If no header records are found, populate this structure if( glob_results->headerrec == NULL ) { for( i = 0; i < argc; i++ ) { - hrec = (_sqlite_header *) malloc(sizeof(_sqlite_header)+2); - memset(hrec, 0, sizeof(_sqlite_header)+2); + hrec = (_sqlite_header *) malloc_nullsafe(NULL, sizeof(_sqlite_header)+2); hrec->fieldid = i; hrec->name = strdup_nullsafe(colName[i]); @@ -134,8 +133,7 @@ static int _cb_parse_result(void *NotUsed, int argc, char **argv, char **colName // Add all data fields for this record into a tuple structure hrec = glob_results->headerrec; for( i = 0; i < argc; i++ ) { - new_frec = (_sqlite_tuples *) malloc(sizeof(_sqlite_tuples)+2); - memset(new_frec, 0, sizeof(_sqlite_tuples)+2); + new_frec = (_sqlite_tuples *) malloc_nullsafe(NULL, sizeof(_sqlite_tuples)+2); // trec contains the head of a new record set with fields if( trec == NULL ) { @@ -221,8 +219,7 @@ dbresult *sqlite_query(eurephiaCTX *ctx, char *fmt, ... ) { // prepare a new (global) result set ... // do not delete the old ones, since we return this "global" // result as a new individual result - glob_results = malloc(sizeof(dbresult)+2); - memset(glob_results, 0, sizeof(dbresult)+2); + glob_results = malloc_nullsafe(ctx, sizeof(dbresult)+2); glob_results->num_tuples = 0; // prepare SQL query @@ -566,11 +563,8 @@ int main() { mwStatistics(3); #endif - ctx = malloc(sizeof(eurephiaCTX)+2); - memset(ctx, 0, sizeof(eurephiaCTX)+2); - - ctx->dbc = malloc(sizeof(eDBconn)+2); - memset(ctx->dbc, 0, sizeof(eDBconn)+2); + ctx = malloc_nullsafe(NULL, sizeof(eurephiaCTX)+2); + ctx->dbc = malloc_nullsafe(NULL, sizeof(eDBconn)+2); rc = sqlite3_open("./vpnaccess", (void *) &ctx->dbc->dbhandle); if( rc ) { |
