Commit 4b456708 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Constify value

parent f0f3c8fd
......@@ -19,7 +19,7 @@
static void
cb_window_icon(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -32,7 +32,7 @@ cb_window_icon(girara_session_t* session, const char* UNUSED(name),
static void
cb_font(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -41,7 +41,7 @@ cb_font(girara_session_t* session, const char* UNUSED(name),
static void
cb_color(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -57,7 +57,7 @@ cb_color(girara_session_t* session, const char* name,
static void
cb_guioptions(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
......@@ -68,7 +68,7 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
bool show_vscrollbar = false;
/* evaluate input */
char* input = (char*) value;
const char* input = value;
const size_t input_length = strlen(input);
for (size_t i = 0; i < input_length; i++) {
......@@ -113,11 +113,11 @@ cb_guioptions(girara_session_t* session, const char* UNUSED(name),
static void
cb_scrollbars(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
girara_setting_type_t UNUSED(type), const void* value, void* UNUSED(data))
{
g_return_if_fail(session != NULL && value != NULL);
const bool val = *(bool*) value;
const bool val = *(const bool*) value;
char* guioptions = NULL;
girara_setting_get(session, "guioptions", &guioptions);
......
......@@ -36,19 +36,19 @@ struct girara_setting_s
};
void
girara_setting_set_value(girara_session_t* session, girara_setting_t* setting, void* value)
girara_setting_set_value(girara_session_t* session, girara_setting_t* setting, const void* value)
{
g_return_if_fail(setting && (value || setting->type == STRING));
switch(setting->type) {
case BOOLEAN:
setting->value.b = *((bool *) value);
setting->value.b = *((const bool *) value);
break;
case FLOAT:
setting->value.f = *((float *) value);
setting->value.f = *((const float *) value);
break;
case INT:
setting->value.i = *((int *) value);
setting->value.i = *((const int *) value);
break;
case STRING:
if (setting->value.s != NULL) {
......@@ -97,7 +97,7 @@ girara_setting_add(girara_session_t* session, const char* name, void* value, gir
}
bool
girara_setting_set(girara_session_t* session, const char* name, void* value)
girara_setting_set(girara_session_t* session, const char* name, const void* value)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(name != NULL, false);
......
......@@ -33,7 +33,7 @@ bool girara_setting_add(girara_session_t* session, const char* name,
* @return TRUE No error occurred
* @return FALSE An error occurred
*/
bool girara_setting_set(girara_session_t* session, const char* name, void* value) GIRARA_VISIBLE;
bool girara_setting_set(girara_session_t* session, const char* name, const void* value) GIRARA_VISIBLE;
/**
* Retrieve the value of a setting. If the setting is a string, the value stored
......@@ -89,6 +89,6 @@ girara_setting_type_t girara_setting_get_type(girara_setting_t* setting) GIRARA_
* @param value The new value
*/
void girara_setting_set_value(girara_session_t* session,
girara_setting_t* setting, void* value) GIRARA_VISIBLE;
girara_setting_t* setting, const void* value) GIRARA_VISIBLE;
#endif
......@@ -144,7 +144,7 @@ typedef enum girara_setting_type_e
* @param data User data
*/
typedef void (*girara_setting_callback_t)(girara_session_t* session,
const char* name, girara_setting_type_t type, void* value, void* data);
const char* name, girara_setting_type_t type, const void* value, void* data);
/**
* Definition of an argument of a shortcut or buffered command
......
......@@ -45,7 +45,7 @@ START_TEST(test_settings_basic) {
static int callback_called = 0;
static void
setting_callback(girara_session_t* session, const char* name, girara_setting_type_t type, void* value, void* data)
setting_callback(girara_session_t* session, const char* name, girara_setting_type_t type, const void* value, void* data)
{
fail_unless(callback_called == 0, NULL);
fail_unless(session != NULL, NULL);
......
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