Commit 82e6fdc6 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Fix dictionary usage and use const where possible.

parent 12185ca6
...@@ -127,7 +127,7 @@ BELLESIP_EXPORT void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_si ...@@ -127,7 +127,7 @@ BELLESIP_EXPORT void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_si
* @return 1 if the key exists, 0 otherwise * @return 1 if the key exists, 0 otherwise
* @todo create unit test * @todo create unit test
*/ */
BELLESIP_EXPORT int belle_sip_dict_haskey(belle_sip_dict_t* obj, const char* key); BELLESIP_EXPORT int belle_sip_dict_haskey(const belle_sip_dict_t* obj, const char* key);
/** /**
* Apply a function for all keys stored in the dictionary * Apply a function for all keys stored in the dictionary
......
...@@ -239,7 +239,7 @@ BELLESIP_EXPORT void* belle_sip_object_data_get( belle_sip_object_t *obj, const ...@@ -239,7 +239,7 @@ BELLESIP_EXPORT void* belle_sip_object_data_get( belle_sip_object_t *obj, const
/** /**
* Return 1 if the key exists in the data store, 0 otherwise * Return 1 if the key exists in the data store, 0 otherwise
**/ **/
BELLESIP_EXPORT int belle_sip_object_data_exists( belle_sip_object_t *obj, const char* name ); BELLESIP_EXPORT int belle_sip_object_data_exists( const belle_sip_object_t *obj, const char* name );
/** /**
* Destroys the named data associated by the name provided. * Destroys the named data associated by the name provided.
......
...@@ -113,7 +113,7 @@ void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_sip_dict_t* dst) ...@@ -113,7 +113,7 @@ void belle_sip_dict_merge( const belle_sip_dict_t* src, belle_sip_dict_t* dst)
belle_sip_object_data_merge(BELLE_SIP_OBJECT(src), BELLE_SIP_OBJECT(dst), belle_sip_dict_string_clone); belle_sip_object_data_merge(BELLE_SIP_OBJECT(src), BELLE_SIP_OBJECT(dst), belle_sip_dict_string_clone);
} }
int belle_sip_dict_haskey(belle_sip_dict_t* obj, const char* key) int belle_sip_dict_haskey(const belle_sip_dict_t* obj, const char* key)
{ {
return belle_sip_object_data_exists(BELLE_SIP_OBJECT(obj), key); return belle_sip_object_data_exists(BELLE_SIP_OBJECT(obj), key);
} }
......
...@@ -285,7 +285,7 @@ int belle_sip_object_data_remove( belle_sip_object_t *obj, const char* name) ...@@ -285,7 +285,7 @@ int belle_sip_object_data_remove( belle_sip_object_t *obj, const char* name)
return !(list_entry!= NULL); return !(list_entry!= NULL);
} }
int belle_sip_object_data_exists( belle_sip_object_t *obj, const char* name ) int belle_sip_object_data_exists( const belle_sip_object_t *obj, const char* name )
{ {
return (belle_sip_list_find_custom(obj->data_store, belle_sip_object_data_find, name) != NULL); return (belle_sip_list_find_custom(obj->data_store, belle_sip_object_data_find, name) != NULL);
} }
...@@ -341,13 +341,14 @@ struct belle_sip_object_foreach_data { ...@@ -341,13 +341,14 @@ struct belle_sip_object_foreach_data {
void* userdata; void* userdata;
}; };
static void belle_sip_object_for_each_cb(void* data, void* userdata) static void belle_sip_object_for_each_cb(void* data, void* pvdata)
{ {
struct belle_sip_object_foreach_data* fd = (struct belle_sip_object_foreach_data*)userdata; struct belle_sip_object_data* it = (struct belle_sip_object_data*)data;
struct belle_sip_object_data* it = (struct belle_sip_object_data*)data; struct belle_sip_object_foreach_data* fd = (struct belle_sip_object_foreach_data*)pvdata;
if( it && fd->apply_func ) if( it && fd->apply_func ){
fd->apply_func(it->name, it->data, userdata); fd->apply_func(it->name, it->data, fd->userdata);
}
} }
void belle_sip_object_data_foreach( const belle_sip_object_t* obj, void (*apply_func)(const char* key, void* data, void* userdata), void* userdata) void belle_sip_object_data_foreach( const belle_sip_object_t* obj, void (*apply_func)(const char* key, void* data, void* userdata), void* userdata)
......
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