Commit cac857cb authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

Use slice API

parent cdc15d1d
...@@ -40,7 +40,7 @@ girara_list_new(void) ...@@ -40,7 +40,7 @@ girara_list_new(void)
girara_list_t* girara_list_t*
girara_list_new2(girara_free_function_t gfree) girara_list_new2(girara_free_function_t gfree)
{ {
girara_list_t* list = g_try_malloc0(sizeof(girara_list_t)); girara_list_t* list = g_slice_new0(girara_list_t);
if (list == NULL) { if (list == NULL) {
return NULL; return NULL;
} }
...@@ -103,7 +103,7 @@ girara_list_free(girara_list_t* list) ...@@ -103,7 +103,7 @@ girara_list_free(girara_list_t* list)
} }
girara_list_clear(list); girara_list_clear(list);
g_free(list); g_slice_free(girara_list_t, list);
} }
void void
...@@ -203,7 +203,7 @@ girara_list_iterator(girara_list_t* list) ...@@ -203,7 +203,7 @@ girara_list_iterator(girara_list_t* list)
return NULL; return NULL;
} }
girara_list_iterator_t* iter = g_try_malloc0(sizeof(girara_list_iterator_t)); girara_list_iterator_t* iter = g_slice_new0(girara_list_iterator_t);
if (iter == NULL) { if (iter == NULL) {
return NULL; return NULL;
} }
...@@ -219,14 +219,7 @@ girara_list_iterator_copy(girara_list_iterator_t* iter) ...@@ -219,14 +219,7 @@ girara_list_iterator_copy(girara_list_iterator_t* iter)
{ {
g_return_val_if_fail(iter != NULL, NULL); g_return_val_if_fail(iter != NULL, NULL);
girara_list_iterator_t* iter2 = g_try_malloc0(sizeof(girara_list_iterator_t)); return g_slice_copy(sizeof(girara_list_iterator_t), iter);
if (iter2 == NULL) {
return NULL;
}
iter2->list = iter->list;
iter2->element = iter->element;
return iter2;
} }
girara_list_iterator_t* girara_list_iterator_t*
...@@ -328,7 +321,7 @@ girara_list_iterator_free(girara_list_iterator_t* iter) ...@@ -328,7 +321,7 @@ girara_list_iterator_free(girara_list_iterator_t* iter)
return; return;
} }
g_free(iter); g_slice_free(girara_list_iterator_t, iter);
} }
size_t size_t
......
...@@ -36,7 +36,7 @@ new_variable(const char* name) ...@@ -36,7 +36,7 @@ new_variable(const char* name)
return NULL; return NULL;
} }
variable_t* variable = g_try_malloc0(sizeof(variable_t)); variable_t* variable = g_slice_new0(variable_t);
if (variable == NULL) { if (variable == NULL) {
return NULL; return NULL;
} }
...@@ -58,7 +58,7 @@ free_variable(void* data) ...@@ -58,7 +58,7 @@ free_variable(void* data)
variable->name = NULL; variable->name = NULL;
variable->value = NULL; variable->value = NULL;
g_free(variable); g_slice_free(variable_t, data);
} }
static int static int
......
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