projects
/
platform
/
upstream
/
libexif.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be a bit more robust in the face of out-of-memory errors.
[platform/upstream/libexif.git]
/
test
/
test-mnote.c
diff --git
a/test/test-mnote.c
b/test/test-mnote.c
index
28422de
..
81d452c
100644
(file)
--- a/
test/test-mnote.c
+++ b/
test/test-mnote.c
@@
-1,6
+1,6
@@
/* exif-mnote.c
*
/* exif-mnote.c
*
- * Copyright 2002 Lutz M
\uffff
ller <lutz@users.sourceforge.net>
+ * Copyright 2002 Lutz M
ue
ller <lutz@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@
-14,8
+14,8
@@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 5
9 Temple Place - Suite 330
,
- * Boston, MA
02111-1307,
USA.
+ * Free Software Foundation, Inc., 5
1 Franklin Street, Fifth Floor
,
+ * Boston, MA
02110-1301
USA.
*/
#include <config.h>
*/
#include <config.h>
@@
-32,10
+32,10
@@
test_exif_data (ExifData *d)
char v[1024], *p;
ExifMnoteData *md;
char v[1024], *p;
ExifMnoteData *md;
-
fprintf (stdout,
"Byte order: %s\n",
+
printf(
"Byte order: %s\n",
exif_byte_order_get_name (exif_data_get_byte_order (d)));
exif_byte_order_get_name (exif_data_get_byte_order (d)));
-
fprintf (stdout,
"Parsing maker note...\n");
+
printf(
"Parsing maker note...\n");
md = exif_data_get_mnote_data (d);
if (!md) {
fprintf (stderr, "Could not parse maker note!\n");
md = exif_data_get_mnote_data (d);
if (!md) {
fprintf (stderr, "Could not parse maker note!\n");
@@
-43,25
+43,25
@@
test_exif_data (ExifData *d)
return 1;
}
return 1;
}
-
fprintf (stdout,
"Increasing ref-count...\n");
+
printf(
"Increasing ref-count...\n");
exif_mnote_data_ref (md);
exif_mnote_data_ref (md);
-
fprintf (stdout,
"Decreasing ref-count...\n");
+
printf(
"Decreasing ref-count...\n");
exif_mnote_data_unref (md);
exif_mnote_data_unref (md);
-
fprintf (stdout,
"Counting entries...\n");
+
printf(
"Counting entries...\n");
c = exif_mnote_data_count (md);
c = exif_mnote_data_count (md);
-
fprintf (stdout,
"Found %i entries.\n", c);
+
printf(
"Found %i entries.\n", c);
for (i = 0; i < c; i++) {
for (i = 0; i < c; i++) {
-
fprintf (stdout,
"Dumping entry number %i...\n", i);
-
fprintf (stdout,
" Name: '%s'\n",
+
printf(
"Dumping entry number %i...\n", i);
+
printf(
" Name: '%s'\n",
exif_mnote_data_get_name (md, i));
exif_mnote_data_get_name (md, i));
-
fprintf (stdout,
" Title: '%s'\n",
+
printf(
" Title: '%s'\n",
exif_mnote_data_get_title (md, i));
exif_mnote_data_get_title (md, i));
-
fprintf (stdout,
" Description: '%s'\n",
+
printf(
" Description: '%s'\n",
exif_mnote_data_get_description (md, i));
p = exif_mnote_data_get_value (md, i, v, sizeof (v));
exif_mnote_data_get_description (md, i));
p = exif_mnote_data_get_value (md, i, v, sizeof (v));
- if (p) {
fprintf (stdout,
" Value: '%s'\n", v); }
+ if (p) {
printf(
" Value: '%s'\n", v); }
}
return 0;
}
return 0;
@@
-80,28
+80,32
@@
main (int argc, char **argv)
return 1;
}
return 1;
}
-
fprintf (stdout,
"Loading '%s'...\n", argv[1]);
+
printf(
"Loading '%s'...\n", argv[1]);
d = exif_data_new_from_file (argv[1]);
if (!d) {
fprintf (stderr, "Could not load data from '%s'!\n", argv[1]);
return 1;
}
d = exif_data_new_from_file (argv[1]);
if (!d) {
fprintf (stderr, "Could not load data from '%s'!\n", argv[1]);
return 1;
}
-
fprintf (stdout,
"Loaded '%s'.\n", argv[1]);
+
printf(
"Loaded '%s'.\n", argv[1]);
-
fprintf (stdout,
"######### Test 1 #########\n");
+
printf(
"######### Test 1 #########\n");
r = test_exif_data (d);
if (r) return r;
exif_data_save_data (d, &buf, &buf_size);
exif_data_unref (d);
d = exif_data_new_from_data (buf, buf_size);
r = test_exif_data (d);
if (r) return r;
exif_data_save_data (d, &buf, &buf_size);
exif_data_unref (d);
d = exif_data_new_from_data (buf, buf_size);
+ if (!d) {
+ fprintf (stderr, "Could not load data from buf!\n");
+ return 1;
+ }
free (buf);
free (buf);
-
fprintf (stdout,
"######### Test 2 #########\n");
+
printf (
"######### Test 2 #########\n");
r = test_exif_data (d);
if (r) return r;
r = test_exif_data (d);
if (r) return r;
-
fprintf (stdout,
"Test successful!\n");
+
printf (
"Test successful!\n");
return 1;
}
return 1;
}