提交 b74397bc 编写于 作者: A Andrey Mazo 提交者: ndevilla

Added const to all unmodified char* arguments.

上级 9f744cc3
......@@ -41,7 +41,7 @@
/* Doubles the allocated size associated to a pointer */
/* 'size' is the current allocated size. */
static void * mem_double(void * ptr, int size)
static void * mem_double(const void * ptr, int size)
{
void * newptr ;
......@@ -64,7 +64,7 @@ static void * mem_double(void * ptr, int size)
for systems that do not have it.
*/
/*--------------------------------------------------------------------------*/
static char * xstrdup(char * s)
static char * xstrdup(const char * s)
{
char * t ;
if (!s)
......@@ -91,7 +91,7 @@ static char * xstrdup(char * s)
by comparing the key itself in last resort.
*/
/*--------------------------------------------------------------------------*/
unsigned dictionary_hash(char * key)
unsigned dictionary_hash(const char * key)
{
int len ;
unsigned hash ;
......@@ -178,7 +178,7 @@ void dictionary_del(dictionary * d)
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)
{
unsigned hash ;
int i ;
......@@ -224,7 +224,7 @@ char * dictionary_get(dictionary * d, char * key, char * def)
This function returns non-zero in case of failure.
*/
/*--------------------------------------------------------------------------*/
int dictionary_set(dictionary * d, char * key, char * val)
int dictionary_set(dictionary * d, const char * key, const char * val)
{
int i ;
unsigned hash ;
......@@ -291,7 +291,7 @@ int dictionary_set(dictionary * d, char * key, char * val)
key cannot be found.
*/
/*--------------------------------------------------------------------------*/
void dictionary_unset(dictionary * d, char * key)
void dictionary_unset(dictionary * d, const char * key)
{
unsigned hash ;
int i ;
......
......@@ -72,7 +72,7 @@ typedef struct _dictionary_ {
by comparing the key itself in last resort.
*/
/*--------------------------------------------------------------------------*/
unsigned dictionary_hash(char * key);
unsigned dictionary_hash(const char * key);
/*-------------------------------------------------------------------------*/
/**
......@@ -112,7 +112,7 @@ void dictionary_del(dictionary * vd);
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);
/*-------------------------------------------------------------------------*/
......@@ -141,7 +141,7 @@ char * dictionary_get(dictionary * d, char * key, char * def);
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, const char * val);
/*-------------------------------------------------------------------------*/
/**
......@@ -154,7 +154,7 @@ int dictionary_set(dictionary * vd, char * key, char * val);
key cannot be found.
*/
/*--------------------------------------------------------------------------*/
void dictionary_unset(dictionary * d, char * key);
void dictionary_unset(dictionary * d, const char * key);
/*-------------------------------------------------------------------------*/
......
......@@ -48,7 +48,7 @@ typedef enum _line_status_ {
allocated, it will be modified at each function call (not re-entrant).
*/
/*--------------------------------------------------------------------------*/
static char * strlwc(char * s)
static char * strlwc(const char * s)
{
static char l[ASCIILINESZ+1];
int i ;
......@@ -78,7 +78,7 @@ static char * strlwc(char * s)
(not re-entrant).
*/
/*--------------------------------------------------------------------------*/
static char * strstrip(char * s)
static char * strstrip(const char * s)
{
static char l[ASCIILINESZ+1];
char * last ;
......@@ -372,7 +372,7 @@ char ** iniparser_getseckeys(dictionary * d, char * s)
the dictionary, do not free or modify it.
*/
/*--------------------------------------------------------------------------*/
char * iniparser_getstring(dictionary * d, char * key, char * def)
char * iniparser_getstring(dictionary * d, const char * key, char * def)
{
char * lc_key ;
char * sval ;
......@@ -412,7 +412,7 @@ char * iniparser_getstring(dictionary * d, char * key, char * def)
Credits: Thanks to A. Becker for suggesting strtol()
*/
/*--------------------------------------------------------------------------*/
int iniparser_getint(dictionary * d, char * key, int notfound)
int iniparser_getint(dictionary * d, const char * key, int notfound)
{
char * str ;
......@@ -434,7 +434,7 @@ int iniparser_getint(dictionary * d, char * key, int notfound)
the notfound value is returned.
*/
/*--------------------------------------------------------------------------*/
double iniparser_getdouble(dictionary * d, char * key, double notfound)
double iniparser_getdouble(dictionary * d, const char * key, double notfound)
{
char * str ;
......@@ -475,7 +475,7 @@ double iniparser_getdouble(dictionary * d, char * key, double notfound)
necessarily have to be 0 or 1.
*/
/*--------------------------------------------------------------------------*/
int iniparser_getboolean(dictionary * d, char * key, int notfound)
int iniparser_getboolean(dictionary * d, const char * key, int notfound)
{
char * c ;
int ret ;
......@@ -506,7 +506,7 @@ int iniparser_getboolean(dictionary * d, char * key, int notfound)
/*--------------------------------------------------------------------------*/
int iniparser_find_entry(
dictionary * ini,
char * entry
const char * entry
)
{
int found=0 ;
......@@ -529,7 +529,7 @@ int iniparser_find_entry(
It is Ok to set val to NULL.
*/
/*--------------------------------------------------------------------------*/
int iniparser_set(dictionary * ini, char * entry, char * val)
int iniparser_set(dictionary * ini, const char * entry, const char * val)
{
return dictionary_set(ini, strlwc(entry), val) ;
}
......@@ -544,7 +544,7 @@ int iniparser_set(dictionary * ini, char * entry, char * val)
If the given entry can be found, it is deleted from the dictionary.
*/
/*--------------------------------------------------------------------------*/
void iniparser_unset(dictionary * ini, char * entry)
void iniparser_unset(dictionary * ini, const char * entry)
{
dictionary_unset(ini, strlwc(entry));
}
......@@ -560,7 +560,7 @@ void iniparser_unset(dictionary * ini, char * entry)
*/
/*--------------------------------------------------------------------------*/
static line_status iniparser_line(
char * input_line,
const char * input_line,
char * section,
char * key,
char * value)
......@@ -633,7 +633,7 @@ static line_status iniparser_line(
The returned dictionary must be freed using iniparser_freedict().
*/
/*--------------------------------------------------------------------------*/
dictionary * iniparser_load(char * ininame)
dictionary * iniparser_load(const char * ininame)
{
FILE * in ;
......
......@@ -159,7 +159,7 @@ char ** iniparser_getseckeys(dictionary * d, char * s);
the dictionary, do not free or modify it.
*/
/*--------------------------------------------------------------------------*/
char * iniparser_getstring(dictionary * d, char * key, char * def);
char * iniparser_getstring(dictionary * d, const char * key, char * def);
/*-------------------------------------------------------------------------*/
/**
......@@ -188,7 +188,7 @@ char * iniparser_getstring(dictionary * d, char * key, char * def);
Credits: Thanks to A. Becker for suggesting strtol()
*/
/*--------------------------------------------------------------------------*/
int iniparser_getint(dictionary * d, char * key, int notfound);
int iniparser_getint(dictionary * d, const char * key, int notfound);
/*-------------------------------------------------------------------------*/
/**
......@@ -203,7 +203,7 @@ int iniparser_getint(dictionary * d, char * key, int notfound);
the notfound value is returned.
*/
/*--------------------------------------------------------------------------*/
double iniparser_getdouble(dictionary * d, char * key, double notfound);
double iniparser_getdouble(dictionary * d, const char * key, double notfound);
/*-------------------------------------------------------------------------*/
/**
......@@ -237,7 +237,7 @@ double iniparser_getdouble(dictionary * d, char * key, double notfound);
necessarily have to be 0 or 1.
*/
/*--------------------------------------------------------------------------*/
int iniparser_getboolean(dictionary * d, char * key, int notfound);
int iniparser_getboolean(dictionary * d, const char * key, int notfound);
/*-------------------------------------------------------------------------*/
......@@ -253,7 +253,7 @@ int iniparser_getboolean(dictionary * d, char * key, int notfound);
It is Ok to set val to NULL.
*/
/*--------------------------------------------------------------------------*/
int iniparser_set(dictionary * ini, char * entry, char * val);
int iniparser_set(dictionary * ini, const char * entry, const char * val);
/*-------------------------------------------------------------------------*/
......@@ -266,7 +266,7 @@ int iniparser_set(dictionary * ini, char * entry, char * val);
If the given entry can be found, it is deleted from the dictionary.
*/
/*--------------------------------------------------------------------------*/
void iniparser_unset(dictionary * ini, char * entry);
void iniparser_unset(dictionary * ini, const char * entry);
/*-------------------------------------------------------------------------*/
/**
......@@ -280,7 +280,7 @@ void iniparser_unset(dictionary * ini, char * entry);
of querying for the presence of sections in a dictionary.
*/
/*--------------------------------------------------------------------------*/
int iniparser_find_entry(dictionary * ini, char * entry) ;
int iniparser_find_entry(dictionary * ini, const char * entry) ;
/*-------------------------------------------------------------------------*/
/**
......@@ -296,7 +296,7 @@ int iniparser_find_entry(dictionary * ini, char * entry) ;
The returned dictionary must be freed using iniparser_freedict().
*/
/*--------------------------------------------------------------------------*/
dictionary * iniparser_load(char * ininame);
dictionary * iniparser_load(const char * ininame);
/*-------------------------------------------------------------------------*/
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册