notashelf /
dc9f159470cb818cdddff1cd0dd6ee083be50eed
chroma
publicLightweight wallpaper daemon for Wayland
clone
ssh://git@git.notashelf.dev:33/notashelf/chroma.gitCommit dc9f159470cb
tarballunverified1 files changed+8-3
@@ -143,6 +143,7 @@ int chroma_image_load(chroma_image_t *image, const char *path, image->data = stbi_load(path, &image->width, &image->height, &image->channels, desired_channels); image->channels = desired_channels;+ image->data_from_stbi = true; if (!image->data) { chroma_log("ERROR", "Failed to load image %s: %s", path, stbi_failure_reason());@@ -227,6 +228,7 @@ int chroma_image_load(chroma_image_t *image, const char *path, stbi_image_free(image->data); image->data = downsampled_data;+ image->data_from_stbi = false; image->width = optimal_width; image->height = optimal_height; @@ -271,8 +273,11 @@ void chroma_image_free(chroma_image_t *image) { chroma_log_resource_deallocation("image_data", image_size, image->path); - // Always use stbi_image_free since we load directly with stbi_load- stbi_image_free(image->data);+ if (image->data_from_stbi) {+ stbi_image_free(image->data);+ } else {+ free(image->data);+ } image->data = NULL; } @@ -291,7 +296,7 @@ void chroma_image_free(chroma_image_t *image) { // Release a reference to an image; free when ref_count reaches zero void chroma_image_release(chroma_image_t *image) {- if (!image) {+ if (!image || !image->loaded) { return; }