summaryrefslogtreecommitdiff
path: root/examples/c/encode
diff options
context:
space:
mode:
authorAndrey Astafyev <dev@246060.ru>2019-11-19 05:38:00 -0800
committerRalph Giles <giles@thaumas.net>2021-06-23 13:24:22 -0700
commita9557c13fa78d73bee0ef44a08057bff6d88acee (patch)
treec45c842c44163aed01dd613e2f6ee01fc402652b /examples/c/encode
parenteba0ff8d3e0bdce6ae8a9aed5479c4aa9ffaf149 (diff)
downloadflac-a9557c13fa78d73bee0ef44a08057bff6d88acee.tar.gz
examples: Fix error condition processing
Don't attempt to attach failed metadata objects. This also avoids clobbering the error flag if attaching the objects should succeed. There may still be problems later, for example calling _delete() on a possibly null metadata object pointer, but this it at least and improvement in the compromise between error handling and readability in C. Signed-off-by: Ralph Giles <giles@thaumas.net>
Diffstat (limited to 'examples/c/encode')
-rw-r--r--examples/c/encode/file/main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/c/encode/file/main.c b/examples/c/encode/file/main.c
index b12d32b1..1066dc37 100644
--- a/examples/c/encode/file/main.c
+++ b/examples/c/encode/file/main.c
@@ -109,11 +109,13 @@ int main(int argc, char *argv[])
) {
fprintf(stderr, "ERROR: out of memory or tag error\n");
ok = false;
- }
+ } else {
+
+ metadata[1]->length = 1234; /* set the padding length */
- metadata[1]->length = 1234; /* set the padding length */
+ ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2);
- ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2);
+ }
}
/* initialize encoder */