Mercurial > hg > sidinfo
changeset 232:03b6f8604a7f
Minor error handling improvements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 04 Jan 2020 11:36:38 +0200 |
parents | bb8ce494267b |
children | b634952372f1 |
files | sidlib.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/sidlib.c Sat Jan 04 11:34:46 2020 +0200 +++ b/sidlib.c Sat Jan 04 11:36:38 2020 +0200 @@ -12,15 +12,23 @@ { char *tmp = th_malloc(len + 1); if (tmp == NULL) + { + th_io_error(ctx, THERR_MALLOC, + "Could not allocate %" PRIu_SIZE_T " bytes for a string.\n", + len); goto err; + } if (!thfread_str(ctx, tmp, len)) + { + th_io_error(ctx, THERR_FREAD, + "Could not read %" PRIu_SIZE_T " bytes from file.\n", + len); goto err; + } tmp[len] = 0; - *str = tmp; - return TRUE; err: @@ -427,10 +435,9 @@ if ((line = th_malloc(SIDLIB_BUFFER_SIZE)) == NULL) { - th_io_error(ctx, THERR_MALLOC, + return th_io_error(ctx, THERR_MALLOC, "Error allocating temporary data buffer of %d bytes.\n", SIDLIB_BUFFER_SIZE); - return ctx->status; } while (thfgets(line, SIDLIB_BUFFER_SIZE, ctx) != NULL)