Commit b7cb7dfd authored by Jon Griffiths's avatar Jon Griffiths

ciniparser: Make key arguments const

Keys are never modified and are likely to be literals in the
real world (as they are in the test cases).
Signed-off-by: default avatarJon Griffiths <jon_p_griffiths@yahoo.com>
parent 8f116a81
...@@ -316,7 +316,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound) ...@@ -316,7 +316,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound)
return (int) strtol(str, NULL, 10); return (int) strtol(str, NULL, 10);
} }
double ciniparser_getdouble(dictionary *d, char *key, double notfound) double ciniparser_getdouble(dictionary *d, const char *key, double notfound)
{ {
char *str; char *str;
......
...@@ -151,7 +151,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound); ...@@ -151,7 +151,7 @@ int ciniparser_getint(dictionary *d, const char *key, int notfound);
* ini file is given as "section:key". If the key cannot be found, * ini file is given as "section:key". If the key cannot be found,
* the notfound value is returned. * the notfound value is returned.
*/ */
double ciniparser_getdouble(dictionary *d, char *key, double notfound); double ciniparser_getdouble(dictionary *d, const char *key, double notfound);
/** /**
* @brief Get the string associated to a key, convert to a boolean * @brief Get the string associated to a key, convert to a boolean
......
...@@ -72,7 +72,7 @@ static void *mem_double(void *ptr, int size) ...@@ -72,7 +72,7 @@ static void *mem_double(void *ptr, int size)
/* The remaining exposed functions are documented in dictionary.h */ /* The remaining exposed functions are documented in dictionary.h */
unsigned dictionary_hash(char *key) unsigned dictionary_hash(const char *key)
{ {
int len; int len;
unsigned hash; unsigned hash;
...@@ -126,7 +126,7 @@ void dictionary_del(dictionary *d) ...@@ -126,7 +126,7 @@ void dictionary_del(dictionary *d)
return; return;
} }
char *dictionary_get(dictionary *d, char *key, char *def) char *dictionary_get(dictionary *d, const char *key, char *def)
{ {
unsigned hash; unsigned hash;
int i; int i;
...@@ -146,7 +146,7 @@ char *dictionary_get(dictionary *d, char *key, char *def) ...@@ -146,7 +146,7 @@ char *dictionary_get(dictionary *d, char *key, char *def)
return def; return def;
} }
int dictionary_set(dictionary *d, char *key, char *val) int dictionary_set(dictionary *d, const char *key, char *val)
{ {
int i; int i;
unsigned hash; unsigned hash;
...@@ -206,7 +206,7 @@ int dictionary_set(dictionary *d, char *key, char *val) ...@@ -206,7 +206,7 @@ int dictionary_set(dictionary *d, char *key, char *val)
return 0; return 0;
} }
void dictionary_unset(dictionary *d, char *key) void dictionary_unset(dictionary *d, const char *key)
{ {
unsigned hash; unsigned hash;
int i; int i;
......
...@@ -76,7 +76,7 @@ typedef struct _dictionary_ { ...@@ -76,7 +76,7 @@ typedef struct _dictionary_ {
* The key is stored anyway in the struct so that collision can be avoided * The key is stored anyway in the struct so that collision can be avoided
* by comparing the key itself in last resort. * by comparing the key itself in last resort.
*/ */
unsigned dictionary_hash(char *key); unsigned dictionary_hash(const char *key);
/** /**
* @brief Create a new dictionary object. * @brief Create a new dictionary object.
...@@ -110,7 +110,7 @@ void dictionary_del(dictionary *vd); ...@@ -110,7 +110,7 @@ void dictionary_del(dictionary *vd);
* dictionary. The returned character pointer points to data internal to the * dictionary. The returned character pointer points to data internal to the
* dictionary object, you should not try to free it or modify it. * dictionary object, you should not try to free it or modify it.
*/ */
char *dictionary_get(dictionary *d, char *key, char *def); char *dictionary_get(dictionary *d, const char *key, char *def);
/** /**
* @brief Set a value in a dictionary. * @brief Set a value in a dictionary.
...@@ -136,7 +136,7 @@ char *dictionary_get(dictionary *d, char *key, char *def); ...@@ -136,7 +136,7 @@ char *dictionary_get(dictionary *d, char *key, char *def);
* *
* This function returns non-zero in case of failure. * This function returns non-zero in case of failure.
*/ */
int dictionary_set(dictionary *vd, char *key, char *val); int dictionary_set(dictionary *vd, const char *key, char *val);
/** /**
* @brief Delete a key in a dictionary * @brief Delete a key in a dictionary
...@@ -147,7 +147,7 @@ int dictionary_set(dictionary *vd, char *key, char *val); ...@@ -147,7 +147,7 @@ int dictionary_set(dictionary *vd, char *key, char *val);
* This function deletes a key in a dictionary. Nothing is done if the * This function deletes a key in a dictionary. Nothing is done if the
* key cannot be found. * key cannot be found.
*/ */
void dictionary_unset(dictionary *d, char *key); void dictionary_unset(dictionary *d, const char *key);
/** /**
* @brief Dump a dictionary to an opened file pointer. * @brief Dump a dictionary to an opened file pointer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment