diff options
author | Max Kellermann <max@duempel.org> | 2011-09-09 21:32:12 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-09 22:55:57 +0200 |
commit | 8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde (patch) | |
tree | f71eb9f9c5dfa789f94eae4182490286b54788ad /src/conf.h | |
parent | c620fd42f4e8c36186c1e3c3523ac6bd1351f91d (diff) | |
download | mpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.tar.gz mpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.tar.xz mpd-8e5f9c8160b5186c93c5d76789ffa88f3e5c2fde.zip |
conf: turn config_get_path() into config_dup_path()
config_get_path() was somewhat flawed, because it pretended to be a
function, when it really had a side effect. The second flaw was that
it did not return the parser error, instead it aborted the whole
process, which is bad style. The new function returns a duplicated
(modified) string that must be freed by the caller, and returns a
GError on failure.
Diffstat (limited to 'src/conf.h')
-rw-r--r-- | src/conf.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/conf.h b/src/conf.h index 8aad9839f..9593501b0 100644 --- a/src/conf.h +++ b/src/conf.h @@ -156,17 +156,15 @@ config_get_string(const char *name, const char *default_value); /** * Returns an optional configuration variable which contains an - * absolute path. If there is a tilde prefix, it is expanded. Aborts - * MPD if the path is not a valid absolute path. + * absolute path. If there is a tilde prefix, it is expanded. + * Returns NULL if the value is not present. If the path could not be + * parsed, returns NULL and sets the error. + * + * The return value must be freed with g_free(). */ -/* We lie here really. This function is not pure as it has side - effects -- it parse the value and creates new string freeing - previous one. However, because this works the very same way each - time (ie. from the outside it appears as if function had no side - effects) we should be in the clear declaring it pure. */ -G_GNUC_PURE -const char * -config_get_path(const char *name); +G_GNUC_MALLOC +char * +config_dup_path(const char *name, GError **error_r); G_GNUC_PURE unsigned |