diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-12-09 15:05:21 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-12-15 17:38:00 +0100 |
commit | fab9febdc3a863c157a56cc4de2418cbb9665844 (patch) | |
tree | 8c442f1f04d67587d91f7f5427d5c90d7a99ff0e /audio/filter/af_export.c | |
parent | c7bf5111c7db05dc5b1750ff285e343849293dd3 (diff) | |
download | mpv-fab9febdc3a863c157a56cc4de2418cbb9665844.tar.bz2 mpv-fab9febdc3a863c157a56cc4de2418cbb9665844.tar.xz |
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.
Diffstat (limited to 'audio/filter/af_export.c')
-rw-r--r-- | audio/filter/af_export.c | 13 |
1 files changed, 7 insertions, 6 deletions
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 <sys/stat.h> #include <fcntl.h> +#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; } |