[Tuxpaint-maintainers] [pere@fornol.no-ip.org: Re: [Tuxpaint-devel] fmemopen alternative (fwd: tuxp
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
From: Bill K. <nb...@so...> - 2010-06-02 22:56:30
|
FYI ----- Forwarded message from Pere Pujal i Carabantes <pe...@fo...> ----- Date: Thu, 03 Jun 2010 00:50:44 +0200 From: Pere Pujal i Carabantes <pe...@fo...> Subject: Re: [Tuxpaint-devel] fmemopen alternative (fwd: tuxpaint-cvs commit message) To: Discussion list for Tux Paint developers <tux...@li...> Reply-To: Discussion list for Tux Paint developers <tux...@li...> A workaround to open_memstream is in CVS, nearly untested, so please check and report issues here or correct in CVS :) Open_memstream or its workaround are called when saving a file that has labels. Pere Update of /cvsroot/tuxpaint/tuxpaint/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26968/src Modified Files: tuxpaint.c Log Message: A workaround to open_memstream. To test it, use the same flag as the fmemopen alternative as usually they come together. Index: tuxpaint.c =================================================================== RCS file: /cvsroot/tuxpaint/tuxpaint/src/tuxpaint.c,v retrieving revision 1.770 retrieving revision 1.771 diff -u -d -r1.770 -r1.771 --- tuxpaint.c 2 Jun 2010 20:02:51 -0000 1.770 +++ tuxpaint.c 2 Jun 2010 22:36:10 -0000 1.771 @@ -12206,7 +12206,7 @@ unsigned char *chunk_data; Bytef *compressed_data; - char *ldata; + char *ldata, *fname; FILE *lfi; int list_ctr = 0; Uint32 pix; @@ -12216,7 +12216,6 @@ 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 @@ 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 @@ 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); ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Tuxpaint-devel mailing list Tux...@li... https://lists.sourceforge.net/lists/listinfo/tuxpaint-devel ----- End forwarded message ----- -- -bill! Sent from my computer |