Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorperepujal <perepujal>2010-06-02 22:36:10 (GMT)
committer perepujal <perepujal>2010-06-02 22:36:10 (GMT)
commitd9409ac07b381670580123cbcfdb8d94afd868b0 (patch)
treed5c6eb164e490eeaf6a90daf48b41e42ad727465
parentec2be67689e22777f6bc37f017d7e50a4ba98790 (diff)
A workaround to open_memstream. To test it, use the same flag as the fmemopen alternative as usually they come together.
-rw-r--r--src/tuxpaint.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/tuxpaint.c b/src/tuxpaint.c
index b95054b..b55ebde 100644
--- a/src/tuxpaint.c
+++ b/src/tuxpaint.c
@@ -12206,7 +12206,7 @@ static void do_png_embed_data(png_structp png_ptr)
unsigned char *chunk_data;
Bytef *compressed_data;
- char *ldata;
+ char *ldata, *fname;
FILE *lfi;
int list_ctr = 0;
Uint32 pix;
@@ -12216,7 +12216,6 @@ static void do_png_embed_data(png_structp png_ptr)
char *char_stream, *line;
size_t dat_size;
- lfi = open_memstream(&ldata, &size_of_uncompressed_label_data);
/* Starter foreground */
if (img_starter)
@@ -12404,6 +12403,22 @@ static void do_png_embed_data(png_structp png_ptr)
free(sbk_pixs);
/* Label data */
+
+#ifndef fmemopen_alternative
+
+ lfi = open_memstream(&ldata, &size_of_uncompressed_label_data);
+
+#else
+#ifndef WIN32
+ fname = get_fname("tmpfile", DIR_SAVE);
+#else
+ fname = get_temp_fname("tmpfile");
+#endif
+
+ lfi = fopen(fname, "w+");
+
+#endif
+
current_node = current_label_node;
while (current_node != NULL)
{
@@ -12471,6 +12486,15 @@ static void do_png_embed_data(png_structp png_ptr)
current_node = current_node->next_to_up_label_node;
printf("cur %p, red %p\n", current_node, first_label_node_in_redo_stack);
}
+
+#ifndef fmemopen_alternative
+ size_of_uncompressed_label_data = ftell(lfi);
+ rewind(lfi);
+ ldata = malloc(size_of_uncompressed_label_data);
+ for (i = 0; i < size_of_uncompressed_label_data; i++)
+ fread(&ldata[i], 1, 1, lfi);
+#endif
+
fclose(lfi);
compressedLen = compressBound(size_of_uncompressed_label_data);