Commit 7db24fd0a9b757e63ffa791663e752d429f1f615

Thomas de Grivel 2023-12-19T09:53:43

win32

diff --git a/libc3/window/cairo/win32/Makefile b/libc3/window/cairo/win32/Makefile
index 0771cac..03a0160 100644
--- a/libc3/window/cairo/win32/Makefile
+++ b/libc3/window/cairo/win32/Makefile
@@ -51,6 +51,15 @@ debug:
 demo: build
 	${MAKE} -C demo demo
 
+demo_asan: asan
+	${MAKE} -C demo demo_asan
+
+demo_cov: cov
+	${MAKE} -C demo demo_cov
+
+demo_debug: debug
+	${MAKE} -C demo demo_debug
+
 distclean:
 	rm -rf ${DISTCLEANFILES}
 	${MAKE} -C demo distclean
diff --git a/libc3/window/cairo/win32/demo/Makefile b/libc3/window/cairo/win32/demo/Makefile
index 34cde24..f519ecf 100644
--- a/libc3/window/cairo/win32/demo/Makefile
+++ b/libc3/window/cairo/win32/demo/Makefile
@@ -43,6 +43,15 @@ debug: ${PROG_DEBUG}
 demo: ${PROG}
 	time ./${PROG}
 
+demo_asan: ${PROG_ASAN}
+	time ./${PROG_ASAN}
+
+demo_cov: ${PROG_COV}
+	time ./${PROG_COV}
+
+demo_debug: ${PROG_DEBUG}
+	time ./${PROG_DEBUG}
+
 distclean:
 	rm -rf ${DISTCLEANFILES}
 
diff --git a/libc3/window/cairo/win32/window_cairo_win32.c b/libc3/window/cairo/win32/window_cairo_win32.c
index e925487..f567141 100644
--- a/libc3/window/cairo/win32/window_cairo_win32.c
+++ b/libc3/window/cairo/win32/window_cairo_win32.c
@@ -25,8 +25,8 @@ bool window_cairo_run (s_window_cairo *window)
   return window_cairo_win32_run(window);
 }
 
-LRESULT CALLBACK window_cairo_win32_proc(HWND hwnd, UINT message,
-                                         WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK window_cairo_win32_proc (HWND hwnd, UINT message,
+					  WPARAM wParam, LPARAM lParam)
 {
   HBITMAP buffer_hbitmap;
   HDC buffer_hdc;
@@ -39,7 +39,6 @@ LRESULT CALLBACK window_cairo_win32_proc(HWND hwnd, UINT message,
   s_window_cairo *window;
   HDC window_hdc;
   window = (s_window_cairo *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
-  assert(window);
   switch (message) {
   case WM_DESTROY:
     printf("WM_DESTROY\n");
@@ -76,6 +75,7 @@ LRESULT CALLBACK window_cairo_win32_proc(HWND hwnd, UINT message,
     DeleteObject(buffer_hbitmap);
     DeleteDC(buffer_hdc);
     DeleteDC(window_hdc);
+    DeleteDC(hdc);
     break;
   case WM_SIZE:
     if (! window->resize(window, LOWORD(lParam), HIWORD(lParam)))
diff --git a/libc3/window/cairo/window_cairo.c b/libc3/window/cairo/window_cairo.c
index db2dbb5..7d4728d 100644
--- a/libc3/window/cairo/window_cairo.c
+++ b/libc3/window/cairo/window_cairo.c
@@ -118,13 +118,15 @@ s_sequence * window_cairo_sequence_init
  f_window_cairo_sequence_load load,
  f_window_cairo_sequence_render render)
 {
+  s_sequence tmp = {0};
   assert(seq);
-  seq->dt = 0.0;
-  seq->t = 0.0;
-  seq->duration = duration;
-  seq->title = title;
-  seq->load = (f_sequence_load) load;
-  seq->render = (f_sequence_render) render;
-  tag_init_void(&seq->tag);
+  tmp.dt = 0.0;
+  tmp.t = 0.0;
+  tmp.duration = duration;
+  tmp.title = title;
+  tmp.load = (f_sequence_load) load;
+  tmp.render = (f_sequence_render) render;
+  tag_init_void(&tmp.tag);
+  *seq = tmp;
   return seq;
 }