Archived
1
0
Fork 0

env.c: free memory at exit.

Make sure the memory for the 'base' string is always free'd
when the program exits.
This commit is contained in:
Henrik Hautakoski 2012-08-09 16:00:20 +02:00
parent b65c9e74aa
commit 107aae0105

7
env.c
View file

@ -29,6 +29,12 @@
static char *base = NULL; static char *base = NULL;
static void free_base() {
if (base)
free(base);
}
static void get_base() { static void get_base() {
struct buffer buf = BUFFER_INIT; struct buffer buf = BUFFER_INIT;
@ -40,6 +46,7 @@ static void get_base() {
buffer_append_str(&buf, "/.dlight"); buffer_append_str(&buf, "/.dlight");
base = buffer_cstr_release(&buf); base = buffer_cstr_release(&buf);
atexit(free_base);
} }
const char* env_get_dir() { const char* env_get_dir() {