<font color='black' size='2' face='arial'><font size="2"><br>
With valgrind I get a lot of uninitialised values with the following program. Everything draws fine. If the radial pattern code gets commented out then these errors don't occur. A little stuck on this one.<br>
<br>
Eric<br>
<br>
<br>
<br>
==3380== Use of uninitialised value of size 4<br>
==3380== at 0x473B1A5: crc32 (in /lib/i386-linux-gnu/libz.so.1.2.8)<br>
==3380== by 0x456E374: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x4576E3F: png_write_chunk_data (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x4576FE5: png_write_chunk (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x457777D: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x45794A4: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x4579B3F: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x4579E60: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x457DD3F: png_write_row (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x457DF7E: png_write_image (in /lib/i386-linux-gnu/libpng12.so.0.54.0)<br>
==3380== by 0x4110033: ??? (in /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6)<br>
==3380== by 0x4110A6A: cairo_surface_write_to_png (in /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6)<br>
==3380== Uninitialised value was created by a stack allocation<br>
==3380== at 0x440AB5E: ??? (in /usr/lib/i386-linux-gnu/libpixman-1.so.0.33.6)<br>
<br>
/* <br>
gcc -Wall -Wextra -g -O0 cairo_test1.c -o cairo_test1 `pkg-config --cflags --libs cairo` -lm<br>
<br>
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./cairo_test1<br>
<br>
Tested on 32bit Ubuntu16.04<br>
*/<br>
<br>
#include<cairo.h><br>
#include<stdio.h><br>
#include<math.h><br>
<br>
int main()<br>
{<br>
int i=0;<br>
double width=400.0;<br>
double height=400.0;<br>
double data[12][2];<br>
cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);<br>
cairo_t *cr=cairo_create(surface);<br>
<br>
for(i=0;i<12;i++)<br>
{<br>
data[i][0]=(width/4)*cos(30.0*(double)(i)*M_PI/180.0);<br>
data[i][1]=(height/4)*sin(30.0*(double)(i)*M_PI/180.0);<br>
}<br>
<br>
cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);<br>
cairo_paint(cr);<br>
<br>
//cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0);<br>
cairo_translate(cr, width/2.0, height/2.0);<br>
cairo_pattern_t *radial1=cairo_pattern_create_radial(0.0, 0.0, 0.0, 0.0, 0.0, width/4.0); <br>
cairo_pattern_add_color_stop_rgba(radial1, 0.0, 1.0, 0.0, 0.0, 1.0);<br>
cairo_pattern_add_color_stop_rgba(radial1, 1.0, 0.0, 0.0, 1.0, 1.0);<br>
cairo_set_source(cr, radial1);<br>
<br>
cairo_move_to(cr, data[0][0], data[0][1]);<br>
for(i=1;i<12;i++)<br>
{<br>
cairo_line_to(cr, data[i][0], data[i][1]);<br>
cairo_stroke_preserve(cr);<br>
}<br>
cairo_close_path(cr);<br>
cairo_fill(cr); <br>
<br>
cairo_surface_write_to_png(surface, "drawing1.png");<br>
printf("Status %i\n", cairo_status(cr));<br>
<br>
cairo_pattern_destroy(radial1);<br>
cairo_destroy(cr);<br>
cairo_surface_destroy(surface);<br>
cairo_debug_reset_static_data();<br>
<br>
return 0;<br>
}</font></font>