Commit cdc15d1d authored by Sebastian Ramacher's avatar Sebastian Ramacher

Avoid function pointer cast

parent 9c3c6ef9
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "input-history.h" #include "input-history.h"
#include "datastructures.h" #include "datastructures.h"
#include "internal.h"
/** /**
* Private data of the input history * Private data of the input history
...@@ -161,7 +162,7 @@ ih_append(GiraraInputHistory* history, const char* input) ...@@ -161,7 +162,7 @@ ih_append(GiraraInputHistory* history, const char* input)
} }
void* data = NULL; void* data = NULL;
while ((data = girara_list_find(list, (girara_compare_function_t) g_strcmp0, data)) != NULL) { while ((data = girara_list_find(list, list_strcmp, data)) != NULL) {
girara_list_remove(list, data); girara_list_remove(list, data);
} }
......
...@@ -150,6 +150,8 @@ HIDDEN bool girara_sc_feedkeys(girara_session_t* session, girara_argument_t* arg ...@@ -150,6 +150,8 @@ HIDDEN bool girara_sc_feedkeys(girara_session_t* session, girara_argument_t* arg
HIDDEN void css_template_fill_font(GiraraTemplate* csstemplate, const char* font); HIDDEN void css_template_fill_font(GiraraTemplate* csstemplate, const char* font);
HIDDEN int list_strcmp(const void* data1, const void* data2);
/** /**
* Structure of a command * Structure of a command
*/ */
......
...@@ -25,8 +25,11 @@ ...@@ -25,8 +25,11 @@
static int static int
cb_sort_settings(girara_setting_t* lhs, girara_setting_t* rhs) cb_sort_settings(const void* data1, const void* data2)
{ {
const girara_setting_t* lhs = data1;
const girara_setting_t* rhs = data2;
return g_strcmp0(girara_setting_get_name(lhs), girara_setting_get_name(rhs)); return g_strcmp0(girara_setting_get_name(lhs), girara_setting_get_name(rhs));
} }
...@@ -314,7 +317,7 @@ girara_session_create(void) ...@@ -314,7 +317,7 @@ girara_session_create(void)
/* settings */ /* settings */
session_private->settings = girara_sorted_list_new2( session_private->settings = girara_sorted_list_new2(
(girara_compare_function_t) cb_sort_settings, cb_sort_settings,
(girara_free_function_t) girara_setting_free); (girara_free_function_t) girara_setting_free);
/* CSS style provider */ /* CSS style provider */
......
...@@ -187,7 +187,7 @@ girara_setting_find(girara_session_t* session, const char* name) ...@@ -187,7 +187,7 @@ girara_setting_find(girara_session_t* session, const char* name)
} }
const char* const char*
girara_setting_get_name(girara_setting_t* setting) { girara_setting_get_name(const girara_setting_t* setting) {
g_return_val_if_fail(setting, NULL); g_return_val_if_fail(setting, NULL);
return setting->name; return setting->name;
} }
......
...@@ -60,7 +60,7 @@ girara_setting_t* girara_setting_find(girara_session_t* session, const char* nam ...@@ -60,7 +60,7 @@ girara_setting_t* girara_setting_find(girara_session_t* session, const char* nam
* @param setting The setting * @param setting The setting
* @return the setting's name * @return the setting's name
*/ */
const char* girara_setting_get_name(girara_setting_t* setting) GIRARA_VISIBLE; const char* girara_setting_get_name(const girara_setting_t* setting) GIRARA_VISIBLE;
/** /**
* Get the setting's value. If the setting is a string, the value stored * Get the setting's value. If the setting is a string, the value stored
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "template.h" #include "template.h"
#include "utils.h" #include "utils.h"
#include "datastructures.h" #include "datastructures.h"
#include "internal.h"
#include <glib.h> #include <glib.h>
...@@ -302,7 +303,7 @@ base_changed(GiraraTemplate* object) ...@@ -302,7 +303,7 @@ base_changed(GiraraTemplate* object)
while (g_match_info_matches(match_info) == true) { while (g_match_info_matches(match_info) == true) {
char* variable = g_match_info_fetch(match_info, 1); char* variable = g_match_info_fetch(match_info, 1);
char* found = girara_list_find(priv->variables_in_base, char* found = girara_list_find(priv->variables_in_base,
(girara_compare_function_t)g_strcmp0, variable); list_strcmp, variable);
if (priv->valid == true) { if (priv->valid == true) {
if (girara_list_find(priv->variables, compare_variable_name, if (girara_list_find(priv->variables, compare_variable_name,
......
...@@ -511,3 +511,12 @@ girara_version(void) ...@@ -511,3 +511,12 @@ girara_version(void)
{ {
return GIRARA_VERSION; return GIRARA_VERSION;
} }
int
list_strcmp(const void* data1, const void* data2)
{
const char* str1 = data1;
const char* str2 = data2;
return g_strcmp0(str1, str2);
}
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