# HG changeset patch # User Matti Hamalainen # Date 1578136735 -7200 # Node ID 609bfc1bd628f5ebf9c38642f74c9ced17fdeda8 # Parent 3cb7be7b98a648d68ae48d700594cd515f80325a Change sidlib_sldb_new() API to int sidlib_sldb_new(SIDLibSLDB **pdbh). diff -r 3cb7be7b98a6 -r 609bfc1bd628 sidinfo.c --- a/sidinfo.c Sat Jan 04 13:11:56 2020 +0200 +++ b/sidinfo.c Sat Jan 04 13:18:55 2020 +0200 @@ -1306,9 +1306,10 @@ setSLDBNewFormat ? ".md5" : ".txt", setSLDBPath); - if ((sidSLDB = sidlib_sldb_new()) == NULL) + if ((ret = sidlib_sldb_new(&sidSLDB)) != THERR_OK) { - THERR("Could not allocate SLDB structure!\n"); + THERR("Could not allocate SLDB database structure: %s\n", + th_error_str(ret)); goto err1; } diff -r 3cb7be7b98a6 -r 609bfc1bd628 sidlib.c --- a/sidlib.c Sat Jan 04 13:11:56 2020 +0200 +++ b/sidlib.c Sat Jan 04 13:18:55 2020 +0200 @@ -421,9 +421,13 @@ } -SIDLibSLDB * sidlib_sldb_new(void) +int sidlib_sldb_new(SIDLibSLDB **pdbh) { - return (SIDLibSLDB *) th_malloc0(sizeof(SIDLibSLDB)); + SIDLibSLDB *dbh; + if ((dbh = *pdbh = (SIDLibSLDB *) th_malloc0(sizeof(SIDLibSLDB))) == NULL) + return THERR_MALLOC; + + return THERR_OK; } diff -r 3cb7be7b98a6 -r 609bfc1bd628 sidlib.h --- a/sidlib.h Sat Jan 04 13:11:56 2020 +0200 +++ b/sidlib.h Sat Jan 04 13:18:55 2020 +0200 @@ -109,7 +109,7 @@ const char * sidlib_get_sid_clock_str(const int flags); const char * sidlib_get_sid_model_str(const int flags); -SIDLibSLDB * sidlib_sldb_new(void); +int sidlib_sldb_new(SIDLibSLDB **pdbh); int sidlib_sldb_read(th_ioctx *ctx, SIDLibSLDB *dbh); int sidlib_sldb_build_index(SIDLibSLDB *dbh); void sidlib_sldb_free(SIDLibSLDB *dbh);