From 02ca05c6b2990ba3401867303ea5c5de0c358897 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 15 Jan 2023 20:14:35 +0100 Subject: Fix memory leak warnings by "binding" images Although the memory "leak" is not really an issue in this demo program (memory is returned anyway), "fixing" the leak warning issued by valgrind and address sanitizer demonstrates the new feature to "bind" images. --- test/pixmap.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/pixmap.cxx b/test/pixmap.cxx index fe79f8758..c8fb54429 100644 --- a/test/pixmap.cxx +++ b/test/pixmap.cxx @@ -1,7 +1,7 @@ // // Pixmap label test program for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -62,8 +62,11 @@ int main(int argc, char **argv) { depixmap = (Fl_Pixmap *)pixmap->copy(); depixmap->inactive(); - b.image(pixmap); - b.deimage(depixmap); + // "bind" images to avoid memory leak reports (valgrind, asan) + // note: these reports are benign because they appear at exit, but anyway + + b.bind_image(pixmap); + b.bind_deimage(depixmap); leftb = new Fl_Toggle_Button(25,50,50,25,"left"); leftb->callback(button_cb); -- cgit v1.2.3