From fab9febdc3a863c157a56cc4de2418cbb9665844 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 9 Dec 2012 15:05:21 +0100 Subject: path: add mp_find_config_file and reorganize some of the code Add `mp_find_config_file` to search different known paths and use that in ass_mp to look for the fontconfig configuration file. Some incidental changes spawned by this feature where: * Buffer allocation for the strings containing the paths is now performed with talloc. All of the allocations are done on a NULL context, but it still improves readability of the code. * Move the OSX function for lookup inside of a bundle: this code path was currently not used by the bundle generated with `make osxbundle`. The plan is to use it again in a future commit to get a fontconfig config file. --- audio/filter/af_export.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'audio') diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c index 2687904ebd..5e3a1869ee 100644 --- a/audio/filter/af_export.c +++ b/audio/filter/af_export.c @@ -37,6 +37,7 @@ #include #include +#include "talloc.h" #include "af.h" #include "core/path.h" @@ -138,18 +139,18 @@ static int control(struct af_instance* af, int cmd, void* arg) char *str = arg; if (!str){ - free(s->filename); + talloc_free(s->filename); - s->filename = get_path(SHARED_FILE); + s->filename = mp_find_user_config_file(SHARED_FILE); return AF_OK; } while((str[i]) && (str[i] != ':')) i++; - free(s->filename); + talloc_free(s->filename); - s->filename = calloc(i + 1, 1); + s->filename = talloc_array_size(NULL, 1, i + 1); memcpy(s->filename, str, i); s->filename[i] = 0; @@ -192,7 +193,7 @@ static void uninit( struct af_instance* af ) if(s->fd > -1) close(s->fd); - free(s->filename); + talloc_free(s->filename); free(af->setup); af->setup = NULL; @@ -259,7 +260,7 @@ static int af_open( struct af_instance* af ) if((af->data == NULL) || (af->setup == NULL)) return AF_ERROR; - ((af_export_t *)af->setup)->filename = get_path(SHARED_FILE); + ((af_export_t *)af->setup)->filename = mp_find_user_config_file(SHARED_FILE); return AF_OK; } -- cgit v1.2.3