summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2014-02-25 20:12:03 +0100
committerGravatar Christian Hesse <mail@eworm.de>2014-02-25 20:12:03 +0100
commit87ec997436fe0c1599869b1bccbf3cb75515030b (patch)
treefe356cb5cb7c464f52d2d4724d89dd1d73531424 /lib
parent94a895c1fa19dfd3c3fcea8538a80fe318db923c (diff)
downloadcqrlogo-87ec997436fe0c1599869b1bccbf3cb75515030b.tar.gz
cqrlogo-87ec997436fe0c1599869b1bccbf3cb75515030b.tar.zst
do the meta stuff only if any meta data is requested
Diffstat (limited to 'lib')
-rw-r--r--lib/libcqrlogo.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/lib/libcqrlogo.c b/lib/libcqrlogo.c
index e1b7a8e..5a83515 100644
--- a/lib/libcqrlogo.c
+++ b/lib/libcqrlogo.c
@@ -75,38 +75,40 @@ struct png_t * generate_png (struct bitmap_t *bitmap, const uint8_t meta, const
png_text *pngtext = NULL;
char *curi = NULL, *libsstr = NULL, *qrver;
- if (meta & CQR_COMMENT)
- pngtext = add_png_text(pngtext, &textcount, "comment", COMMENTSTR);
+ if (meta) {
+ if (meta & CQR_COMMENT)
+ pngtext = add_png_text(pngtext, &textcount, "comment", COMMENTSTR);
- if (meta & CQR_REFERER) {
- curi = strdup(uri);
+ if (meta & CQR_REFERER) {
+ curi = strdup(uri);
- /* text in png file may have a max length of 79 chars */
- if (strlen(curi) > 79)
- sprintf(curi + 76, "...");
+ /* text in png file may have a max length of 79 chars */
+ if (strlen(curi) > 79)
+ sprintf(curi + 76, "...");
- pngtext = add_png_text(pngtext, &textcount, "referer", curi);
- }
+ pngtext = add_png_text(pngtext, &textcount, "referer", curi);
+ }
- if (meta & CQR_VERSION)
- pngtext = add_png_text(pngtext, &textcount, "version", VERSIONSTR);
+ if (meta & CQR_VERSION)
+ pngtext = add_png_text(pngtext, &textcount, "version", VERSIONSTR);
- if (meta & CQR_LIBVERSION) {
- qrver = QRcode_APIVersionString();
+ if (meta & CQR_LIBVERSION) {
+ qrver = QRcode_APIVersionString();
- libsstr = malloc(sizeof(LIBSSTR) + strlen(qrver) + strlen(png_libpng_ver) + strlen(zlib_version));
- sprintf(libsstr, LIBSSTR, qrver, png_libpng_ver, zlib_version);
+ libsstr = malloc(sizeof(LIBSSTR) + strlen(qrver) + strlen(png_libpng_ver) + strlen(zlib_version));
+ sprintf(libsstr, LIBSSTR, qrver, png_libpng_ver, zlib_version);
- pngtext = add_png_text(pngtext, &textcount, "libs", libsstr);
- }
+ pngtext = add_png_text(pngtext, &textcount, "libs", libsstr);
+ }
- png_set_text(png_ptr, info_ptr, pngtext, textcount);
- png_free (png_ptr, pngtext);
+ png_set_text(png_ptr, info_ptr, pngtext, textcount);
+ png_free (png_ptr, pngtext);
- if (curi)
- free(curi);
- if (libsstr)
- free(libsstr);
+ if (curi)
+ free(curi);
+ if (libsstr)
+ free(libsstr);
+ }
#endif
row_pointers = png_malloc (png_ptr, bitmap->height * sizeof (png_byte *));