Mercurial > hg > sidinfo
changeset 236:609bfc1bd628
Change sidlib_sldb_new() API to int sidlib_sldb_new(SIDLibSLDB **pdbh).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 04 Jan 2020 13:18:55 +0200 |
parents | 3cb7be7b98a6 |
children | d28f3d537284 |
files | sidinfo.c sidlib.c sidlib.h |
diffstat | 3 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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; }
--- 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);