From d8d170aa5ee1498babee095078b3888f1525a2b3 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 8 Apr 2022 13:44:49 +0000 Subject: allow add_mime to fail add_mime nows allocate dinamically copies of the passed strings, so that we can actually free what we parse from the config file. This matters a lot especially with lengthy `types' block: strings that reach the internal mapping are never free'd, so every manual addition is leaked. --- gmid.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gmid.h') diff --git a/gmid.h b/gmid.h index 4572db3..4acbf71 100644 --- a/gmid.h +++ b/gmid.h @@ -176,8 +176,8 @@ struct vhost { }; struct etm { /* extension to mime */ - const char *mime; - const char *ext; + char *mime; + char *ext; }; struct mime { @@ -353,9 +353,10 @@ int logger_main(int, struct imsgbuf*); /* mime.c */ void init_mime(struct mime*); -void add_mime(struct mime*, const char*, const char*); -void load_default_mime(struct mime*); +int add_mime(struct mime*, const char*, const char*); +int load_default_mime(struct mime*); const char *mime(struct vhost*, const char*); +void free_mime(struct mime *); /* server.c */ extern int shutting_down; -- cgit v1.2.3