Skip to content

Commit

Permalink
lua-imlib2: fix memory leak
Browse files Browse the repository at this point in the history
If you frequently use this function to draw new images this leak
becomes quite significant
  • Loading branch information
simotek committed Nov 18, 2024
1 parent a0ee703 commit 3fb7684
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/libcairo_imlib2_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Please see COPYING for details
*
* Copyright (c) 2005-2024 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* (see AUTHORS)
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -61,7 +61,6 @@ void cairo_place_image(const char *file, cairo_t *cr, int x, int y,
return;
}

/* create scaled version of image to later extract the alpha channel */
alpha_image = imlib_create_cropped_scaled_image(0, 0, w, h, width, height);

/* create temporary image */
Expand Down Expand Up @@ -151,6 +150,8 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y,

cr = cairo_create(cs);
cairo_place_image(file, cr, x, y, scaled_w, scaled_h, 1.0);
imlib_context_set_image(image);
imlib_free_image_and_decache();

cairo_destroy(cr);
}
Expand Down

0 comments on commit 3fb7684

Please sign in to comment.