Add separate function to free RawImage

This commit is contained in:
Benedikt Heine 2017-10-29 13:40:43 +01:00
parent e111f5393e
commit 13ed6301d8
2 changed files with 15 additions and 5 deletions

View File

@ -163,6 +163,19 @@ int notification_is_duplicate(const notification *a, const notification *b)
&& a->urgency == b->urgency; && a->urgency == b->urgency;
} }
/*
* Free a #RawImage
* @i: (nullable): pointer to #RawImage
*/
void rawimage_free(RawImage *i)
{
if (!i)
return;
g_free(i->data);
g_free(i);
}
/* /*
* Free the memory used by the given notification. * Free the memory used by the given notification.
*/ */
@ -184,11 +197,7 @@ void notification_free(notification *n)
g_free(n->actions->dmenu_str); g_free(n->actions->dmenu_str);
} }
if (n->raw_icon) { rawimage_free(n->raw_icon);
if (n->raw_icon->data)
g_free(n->raw_icon->data);
g_free(n->raw_icon);
}
g_free(n); g_free(n);
} }

View File

@ -63,6 +63,7 @@ typedef struct _notification {
notification *notification_create(void); notification *notification_create(void);
void notification_init(notification *n); void notification_init(notification *n);
void rawimage_free(RawImage *i);
void notification_free(notification *n); void notification_free(notification *n);
int notification_cmp(const void *a, const void *b); int notification_cmp(const void *a, const void *b);
int notification_cmp_data(const void *a, const void *b, void *data); int notification_cmp_data(const void *a, const void *b, void *data);