cogl: Stop using GSlice

It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
This commit is contained in:
Robert Mader 2020-10-18 13:46:08 +02:00
parent ddca606b58
commit df4508e8cf
44 changed files with 133 additions and 139 deletions

View File

@ -100,7 +100,7 @@ struct _CoglPangoDisplayListNode
CoglPangoDisplayList *
_cogl_pango_display_list_new (CoglPangoPipelineCache *pipeline_cache)
{
CoglPangoDisplayList *dl = g_slice_new0 (CoglPangoDisplayList);
CoglPangoDisplayList *dl = g_new0 (CoglPangoDisplayList, 1);
dl->pipeline_cache = pipeline_cache;
@ -161,7 +161,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
else
{
/* Otherwise create a new node */
node = g_slice_new (CoglPangoDisplayListNode);
node = g_new0 (CoglPangoDisplayListNode, 1);
node->type = COGL_PANGO_DISPLAY_LIST_TEXTURE;
node->color_override = dl->color_override;
@ -195,7 +195,7 @@ _cogl_pango_display_list_add_rectangle (CoglPangoDisplayList *dl,
float x_1, float y_1,
float x_2, float y_2)
{
CoglPangoDisplayListNode *node = g_slice_new (CoglPangoDisplayListNode);
CoglPangoDisplayListNode *node = g_new0 (CoglPangoDisplayListNode, 1);
node->type = COGL_PANGO_DISPLAY_LIST_RECTANGLE;
node->color_override = dl->color_override;
@ -219,7 +219,7 @@ _cogl_pango_display_list_add_trapezoid (CoglPangoDisplayList *dl,
float x_22)
{
CoglContext *ctx = dl->pipeline_cache->ctx;
CoglPangoDisplayListNode *node = g_slice_new (CoglPangoDisplayListNode);
CoglPangoDisplayListNode *node = g_new0 (CoglPangoDisplayListNode, 1);
CoglVertexP2 vertices[4] = {
{ x_11, y_1 },
{ x_12, y_2 },
@ -470,7 +470,7 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
if (node->pipeline)
cogl_object_unref (node->pipeline);
g_slice_free (CoglPangoDisplayListNode, node);
g_free (node);
}
void
@ -486,5 +486,5 @@ void
_cogl_pango_display_list_free (CoglPangoDisplayList *dl)
{
_cogl_pango_display_list_clear (dl);
g_slice_free (CoglPangoDisplayList, dl);
g_free (dl);
}

View File

@ -77,14 +77,14 @@ cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
{
if (value->texture)
cogl_object_unref (value->texture);
g_slice_free (CoglPangoGlyphCacheValue, value);
g_free (value);
}
static void
cogl_pango_glyph_cache_key_free (CoglPangoGlyphCacheKey *key)
{
g_object_unref (key->font);
g_slice_free (CoglPangoGlyphCacheKey, key);
g_free (key);
}
static unsigned int
@ -326,7 +326,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
CoglPangoGlyphCacheKey *key;
PangoRectangle ink_rect;
value = g_slice_new (CoglPangoGlyphCacheValue);
value = g_new0 (CoglPangoGlyphCacheValue, 1);
value->texture = NULL;
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
@ -362,7 +362,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
cache->has_dirty_glyphs = TRUE;
}
key = g_slice_new (CoglPangoGlyphCacheKey);
key = g_new0 (CoglPangoGlyphCacheKey, 1);
key->font = g_object_ref (font);
key->glyph = glyph;

View File

@ -69,7 +69,7 @@ _cogl_pango_pipeline_cache_value_destroy (void *data)
/* We don't need to unref the pipeline because it only takes a weak
reference */
g_slice_free (CoglPangoPipelineCacheEntry, cache_entry);
g_free (cache_entry);
}
CoglPangoPipelineCache *
@ -164,7 +164,7 @@ pipeline_destroy_notify_cb (void *user_data)
PipelineDestroyNotifyData *data = user_data;
g_hash_table_remove (data->cache->hash_table, data->texture);
g_slice_free (PipelineDestroyNotifyData, data);
g_free (data);
}
CoglPipeline *
@ -182,7 +182,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
return cogl_object_ref (entry->pipeline);
/* No existing pipeline was found so let's create another */
entry = g_slice_new (CoglPangoPipelineCacheEntry);
entry = g_new0 (CoglPangoPipelineCacheEntry, 1);
if (texture)
{
@ -207,7 +207,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
/* Add a weak reference to the pipeline so we can remove it from the
hash table when it is destroyed */
destroy_data = g_slice_new (PipelineDestroyNotifyData);
destroy_data = g_new0 (PipelineDestroyNotifyData, 1);
destroy_data->cache = cache;
destroy_data->texture = texture;
cogl_object_set_user_data (COGL_OBJECT (entry->pipeline),

View File

@ -365,7 +365,7 @@ cogl_pango_render_qdata_destroy (CoglPangoLayoutQdata *qdata)
cogl_pango_layout_qdata_forget_display_list (qdata);
if (qdata->first_line)
pango_layout_line_unref (qdata->first_line);
g_slice_free (CoglPangoLayoutQdata, qdata);
g_free (qdata);
}
void
@ -389,7 +389,7 @@ cogl_pango_show_layout (CoglFramebuffer *fb,
if (qdata == NULL)
{
qdata = g_slice_new0 (CoglPangoLayoutQdata);
qdata = g_new0 (CoglPangoLayoutQdata, 1);
qdata->renderer = priv;
g_object_set_qdata_full (G_OBJECT (layout),
cogl_pango_layout_get_qdata_key (),

View File

@ -48,7 +48,7 @@ CoglAttributeBuffer *
cogl_attribute_buffer_new_with_size (CoglContext *context,
size_t bytes)
{
CoglAttributeBuffer *buffer = g_slice_new (CoglAttributeBuffer);
CoglAttributeBuffer *buffer = g_new0 (CoglAttributeBuffer, 1);
/* parent's constructor */
_cogl_buffer_initialize (COGL_BUFFER (buffer),
@ -97,6 +97,6 @@ _cogl_attribute_buffer_free (CoglAttributeBuffer *array)
/* parent's destructor */
_cogl_buffer_fini (COGL_BUFFER (array));
g_slice_free (CoglAttributeBuffer, array);
g_free (array);
}

View File

@ -190,7 +190,7 @@ cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
int n_components,
CoglAttributeType type)
{
CoglAttribute *attribute = g_slice_new (CoglAttribute);
CoglAttribute *attribute = g_new0 (CoglAttribute, 1);
CoglBuffer *buffer = COGL_BUFFER (attribute_buffer);
CoglContext *ctx = buffer->context;
@ -240,7 +240,7 @@ _cogl_attribute_new_const (CoglContext *context,
gboolean transpose,
const float *value)
{
CoglAttribute *attribute = g_slice_new (CoglAttribute);
CoglAttribute *attribute = g_new0 (CoglAttribute, 1);
attribute->name_state =
g_hash_table_lookup (context->attribute_name_states_hash, name);
@ -521,7 +521,7 @@ _cogl_attribute_free (CoglAttribute *attribute)
else
_cogl_boxed_value_destroy (&attribute->d.constant.boxed);
g_slice_free (CoglAttribute, attribute);
g_free (attribute);
}
static gboolean

View File

@ -58,7 +58,7 @@ _cogl_bitmap_free (CoglBitmap *bmp)
if (bmp->buffer)
cogl_object_unref (bmp->buffer);
g_slice_free (CoglBitmap, bmp);
g_free (bmp);
}
gboolean
@ -190,7 +190,7 @@ cogl_bitmap_new_for_data (CoglContext *context,
if (rowstride == 0)
rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0);
bmp = g_slice_new (CoglBitmap);
bmp = g_new0 (CoglBitmap, 1);
bmp->context = context;
bmp->format = format;
bmp->width = width;

View File

@ -53,7 +53,7 @@ _cogl_clip_stack_push_entry (CoglClipStack *clip_stack,
size_t size,
CoglClipStackType type)
{
CoglClipStack *entry = g_slice_alloc (size);
CoglClipStack *entry = g_malloc0 (size);
/* The new entry starts with a ref count of 1 because the stack
holds a reference to it as it is the top entry */
@ -341,11 +341,11 @@ _cogl_clip_stack_unref (CoglClipStack *entry)
{
CoglClipStackRect *rect = (CoglClipStackRect *) entry;
cogl_matrix_entry_unref (rect->matrix_entry);
g_slice_free1 (sizeof (CoglClipStackRect), entry);
g_free (entry);
break;
}
case COGL_CLIP_STACK_WINDOW_RECT:
g_slice_free1 (sizeof (CoglClipStackWindowRect), entry);
g_free (entry);
break;
case COGL_CLIP_STACK_PRIMITIVE:
{
@ -353,14 +353,14 @@ _cogl_clip_stack_unref (CoglClipStack *entry)
(CoglClipStackPrimitive *) entry;
cogl_matrix_entry_unref (primitive_entry->matrix_entry);
cogl_object_unref (primitive_entry->primitive);
g_slice_free1 (sizeof (CoglClipStackPrimitive), entry);
g_free (entry);
break;
}
case COGL_CLIP_STACK_REGION:
{
CoglClipStackRegion *region = (CoglClipStackRegion *) entry;
cairo_region_destroy (region->region);
g_slice_free1 (sizeof (CoglClipStackRegion), entry);
g_free (entry);
break;
}
default:

View File

@ -41,7 +41,7 @@ _cogl_closure_disconnect (CoglClosure *closure)
if (closure->destroy_cb)
closure->destroy_cb (closure->user_data);
g_slice_free (CoglClosure, closure);
g_free (closure);
}
void
@ -59,7 +59,7 @@ _cogl_closure_list_add (CoglList *list,
void *user_data,
CoglUserDataDestroyCallback destroy_cb)
{
CoglClosure *closure = g_slice_new (CoglClosure);
CoglClosure *closure = g_new0 (CoglClosure, 1);
closure->function = function;
closure->user_data = user_data;

View File

@ -42,14 +42,14 @@ COGL_GTYPE_DEFINE_BOXED (Color, color, cogl_color_copy, cogl_color_free);
CoglColor *
cogl_color_new (void)
{
return g_slice_new (CoglColor);
return g_new0 (CoglColor, 1);
}
CoglColor *
cogl_color_copy (const CoglColor *color)
{
if (G_LIKELY (color))
return g_slice_dup (CoglColor, color);
return g_memdup2 (color, sizeof (CoglColor));
return NULL;
}
@ -58,7 +58,7 @@ void
cogl_color_free (CoglColor *color)
{
if (G_LIKELY (color))
g_slice_free (CoglColor, color);
g_free (color);
}
void

View File

@ -79,14 +79,14 @@ _cogl_display_free (CoglDisplay *display)
display->onscreen_template = NULL;
}
g_slice_free (CoglDisplay, display);
g_free (display);
}
CoglDisplay *
cogl_display_new (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template)
{
CoglDisplay *display = g_slice_new0 (CoglDisplay);
CoglDisplay *display = g_new0 (CoglDisplay, 1);
GError *error = NULL;
_cogl_init ();

View File

@ -164,7 +164,7 @@ cogl_framebuffer_add_fence_callback (CoglFramebuffer *framebuffer,
if (!COGL_FLAGS_GET (context->features, COGL_FEATURE_ID_FENCE))
return NULL;
fence = g_slice_new (CoglFenceClosure);
fence = g_new0 (CoglFenceClosure, 1);
fence->framebuffer = framebuffer;
fence->callback = callback;
fence->user_data = user_data;
@ -209,7 +209,7 @@ cogl_framebuffer_cancel_fence_callback (CoglFramebuffer *framebuffer,
#endif
}
g_slice_free (CoglFenceClosure, fence);
g_free (fence);
}
void

View File

@ -43,7 +43,7 @@ cogl_frame_info_new (int64_t global_frame_counter)
{
CoglFrameInfo *info;
info = g_slice_new0 (CoglFrameInfo);
info = g_new0 (CoglFrameInfo, 1);
info->global_frame_counter = global_frame_counter;
return _cogl_frame_info_object_new (info);
@ -52,7 +52,7 @@ cogl_frame_info_new (int64_t global_frame_counter)
static void
_cogl_frame_info_free (CoglFrameInfo *info)
{
g_slice_free (CoglFrameInfo, info);
g_free (info);
}
int64_t

View File

@ -50,7 +50,7 @@ COGL_GTYPE_DEFINE_CLASS (IndexBuffer, index_buffer);
CoglIndexBuffer *
cogl_index_buffer_new (CoglContext *context, size_t bytes)
{
CoglIndexBuffer *indices = g_slice_new (CoglIndexBuffer);
CoglIndexBuffer *indices = g_new0 (CoglIndexBuffer, 1);
/* parent's constructor */
_cogl_buffer_initialize (COGL_BUFFER (indices),
@ -69,7 +69,7 @@ _cogl_index_buffer_free (CoglIndexBuffer *indices)
/* parent's destructor */
_cogl_buffer_fini (COGL_BUFFER (indices));
g_slice_free (CoglIndexBuffer, indices);
g_free (indices);
}
/* XXX: do we want a convenience function like this as an alternative

View File

@ -69,7 +69,7 @@ cogl_indices_new_for_buffer (CoglIndicesType type,
CoglIndexBuffer *buffer,
size_t offset)
{
CoglIndices *indices = g_slice_new (CoglIndices);
CoglIndices *indices = g_new0 (CoglIndices, 1);
indices->buffer = cogl_object_ref (buffer);
indices->offset = offset;
@ -161,7 +161,7 @@ static void
_cogl_indices_free (CoglIndices *indices)
{
cogl_object_unref (indices->buffer);
g_slice_free (CoglIndices, indices);
g_free (indices);
}
CoglIndices *

View File

@ -140,13 +140,13 @@ _cogl_journal_free (CoglJournal *journal)
if (journal->vbo_pool[i])
cogl_object_unref (journal->vbo_pool[i]);
g_slice_free (CoglJournal, journal);
g_free (journal);
}
CoglJournal *
_cogl_journal_new (CoglFramebuffer *framebuffer)
{
CoglJournal *journal = g_slice_new0 (CoglJournal);
CoglJournal *journal = g_new0 (CoglJournal, 1);
journal->framebuffer = framebuffer;
journal->entries = g_array_new (FALSE, FALSE, sizeof (CoglJournalEntry));

View File

@ -513,13 +513,13 @@ static void
_cogl_matrix_stack_free (CoglMatrixStack *stack)
{
cogl_matrix_entry_unref (stack->last_entry);
g_slice_free (CoglMatrixStack, stack);
g_free (stack);
}
CoglMatrixStack *
cogl_matrix_stack_new (CoglContext *ctx)
{
CoglMatrixStack *stack = g_slice_new (CoglMatrixStack);
CoglMatrixStack *stack = g_new0 (CoglMatrixStack, 1);
if (G_UNLIKELY (cogl_matrix_stack_magazine == NULL))
{

View File

@ -81,7 +81,7 @@ struct _CoglMemoryStack
static CoglMemorySubStack *
_cogl_memory_sub_stack_alloc (size_t bytes)
{
CoglMemorySubStack *sub_stack = g_slice_new (CoglMemorySubStack);
CoglMemorySubStack *sub_stack = g_new0 (CoglMemorySubStack, 1);
sub_stack->bytes = bytes;
sub_stack->data = g_malloc (bytes);
return sub_stack;
@ -101,7 +101,7 @@ _cogl_memory_stack_add_sub_stack (CoglMemoryStack *stack,
CoglMemoryStack *
_cogl_memory_stack_new (size_t initial_size_bytes)
{
CoglMemoryStack *stack = g_slice_new0 (CoglMemoryStack);
CoglMemoryStack *stack = g_new0 (CoglMemoryStack, 1);
_cogl_list_init (&stack->sub_stacks);
@ -175,7 +175,7 @@ static void
_cogl_memory_sub_stack_free (CoglMemorySubStack *sub_stack)
{
g_free (sub_stack->data);
g_slice_free (CoglMemorySubStack, sub_stack);
g_free (sub_stack);
}
void
@ -190,5 +190,5 @@ _cogl_memory_stack_free (CoglMemoryStack *stack)
_cogl_memory_sub_stack_free (sub_stack);
}
g_slice_free (CoglMemoryStack, stack);
g_free (stack);
}

View File

@ -47,13 +47,13 @@ COGL_GTYPE_DEFINE_CLASS (OnscreenTemplate, onscreen_template);
static void
_cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template)
{
g_slice_free (CoglOnscreenTemplate, onscreen_template);
g_free (onscreen_template);
}
CoglOnscreenTemplate *
cogl_onscreen_template_new (CoglSwapChain *swap_chain)
{
CoglOnscreenTemplate *onscreen_template = g_slice_new0 (CoglOnscreenTemplate);
CoglOnscreenTemplate *onscreen_template = g_new0 (CoglOnscreenTemplate, 1);
char *user_config;
onscreen_template->config.swap_chain = swap_chain;

View File

@ -204,7 +204,7 @@ _cogl_dispatch_onscreen_cb (CoglContext *context)
g_object_unref (onscreen);
cogl_object_unref (info);
g_slice_free (CoglOnscreenEvent, event);
g_free (event);
}
while (!_cogl_list_empty (&context->onscreen_dirty_queue))
@ -225,7 +225,7 @@ _cogl_dispatch_onscreen_cb (CoglContext *context)
g_object_unref (qe->onscreen);
g_slice_free (CoglOnscreenQueuedDirty, qe);
g_free (qe);
}
}
@ -252,7 +252,7 @@ _cogl_onscreen_queue_dirty (CoglOnscreen *onscreen,
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglOnscreenQueuedDirty *qe = g_slice_new (CoglOnscreenQueuedDirty);
CoglOnscreenQueuedDirty *qe = g_new0 (CoglOnscreenQueuedDirty, 1);
qe->onscreen = g_object_ref (onscreen);
qe->info = *info;
@ -283,7 +283,7 @@ _cogl_onscreen_queue_event (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglOnscreenEvent *event = g_slice_new (CoglOnscreenEvent);
CoglOnscreenEvent *event = g_new0 (CoglOnscreenEvent, 1);
event->onscreen = g_object_ref (onscreen);
event->info = cogl_object_ref (info);

View File

@ -45,7 +45,7 @@ _cogl_output_new (const char *name)
{
CoglOutput *output;
output = g_slice_new0 (CoglOutput);
output = g_new0 (CoglOutput, 1);
output->name = g_strdup (name);
return _cogl_output_object_new (output);
@ -56,7 +56,7 @@ _cogl_output_free (CoglOutput *output)
{
g_free (output->name);
g_slice_free (CoglOutput, output);
g_free (output);
}
gboolean

View File

@ -66,7 +66,7 @@ value_destroy_cb (void *value)
cogl_object_unref (entry->parent.pipeline);
g_slice_free (CoglPipelineHashTableEntry, entry);
g_free (entry);
}
static unsigned int
@ -206,7 +206,7 @@ _cogl_pipeline_hash_table_get (CoglPipelineHashTable *hash,
if (g_hash_table_size (hash->table) >= hash->expected_min_size * 2)
prune_old_pipelines (hash);
entry = g_slice_new (CoglPipelineHashTableEntry);
entry = g_new0 (CoglPipelineHashTableEntry, 1);
entry->parent.usage_count = 0;
entry->hash = hash;
entry->hash_value = dummy_entry.hash_value;

View File

@ -161,7 +161,7 @@ _cogl_pipeline_layer_copy_differences (CoglPipelineLayer *dest,
if ((differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE) &&
!dest->has_big_state)
{
dest->big_state = g_slice_new (CoglPipelineLayerBigState);
dest->big_state = g_new0 (CoglPipelineLayerBigState, 1);
dest->has_big_state = TRUE;
}
@ -408,7 +408,7 @@ init_layer_state:
if (change & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE &&
!layer->has_big_state)
{
layer->big_state = g_slice_new (CoglPipelineLayerBigState);
layer->big_state = g_new0 (CoglPipelineLayerBigState, 1);
layer->has_big_state = TRUE;
}
@ -457,7 +457,7 @@ _cogl_pipeline_layer_set_parent (CoglPipelineLayer *layer,
CoglPipelineLayer *
_cogl_pipeline_layer_copy (CoglPipelineLayer *src)
{
CoglPipelineLayer *layer = g_slice_new (CoglPipelineLayer);
CoglPipelineLayer *layer = g_new0 (CoglPipelineLayer, 1);
_cogl_pipeline_node_init (COGL_NODE (layer));
@ -712,17 +712,17 @@ _cogl_pipeline_layer_free (CoglPipelineLayer *layer)
_cogl_pipeline_snippet_list_free (&layer->big_state->fragment_snippets);
if (layer->differences & COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE)
g_slice_free (CoglPipelineLayerBigState, layer->big_state);
g_free (layer->big_state);
g_slice_free (CoglPipelineLayer, layer);
g_free (layer);
}
void
_cogl_pipeline_init_default_layers (void)
{
CoglPipelineLayer *layer = g_slice_new0 (CoglPipelineLayer);
CoglPipelineLayer *layer = g_new0 (CoglPipelineLayer, 1);
CoglPipelineLayerBigState *big_state =
g_slice_new0 (CoglPipelineLayerBigState);
g_new0 (CoglPipelineLayerBigState, 1);
CoglPipelineLayer *new;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);

View File

@ -635,7 +635,7 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
* static void
* destroy_cache_cb (CoglObject *object, void *user_data)
* {
* g_slice_free (MyValidatedMaterialCache, user_data);
* g_free (user_data);
* }
*
* static void
@ -654,7 +654,7 @@ _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
* &_cogl_my_cache_key);
* if (G_UNLIKELY (cache == NULL))
* {
* cache = g_slice_new (MyValidatedMaterialCache);
* cache = g_new0 (MyValidatedMaterialCache, 1);
* cogl_object_set_user_data (COGL_OBJECT (source),
* &_cogl_my_cache_key,
* cache, destroy_cache_cb);

View File

@ -80,10 +80,10 @@ void
_cogl_pipeline_init_default_pipeline (void)
{
/* Create new - blank - pipeline */
CoglPipeline *pipeline = g_slice_new0 (CoglPipeline);
CoglPipeline *pipeline = g_new0 (CoglPipeline, 1);
/* XXX: NB: It's important that we zero this to avoid polluting
* pipeline hash values with un-initialized data */
CoglPipelineBigState *big_state = g_slice_new0 (CoglPipelineBigState);
CoglPipelineBigState *big_state = g_new0 (CoglPipelineBigState, 1);
CoglPipelineAlphaFuncState *alpha_state = &big_state->alpha_state;
CoglPipelineBlendState *blend_state = &big_state->blend_state;
CoglPipelineCullFaceState *cull_face_state = &big_state->cull_face_state;
@ -180,8 +180,7 @@ recursively_free_layer_caches (CoglPipeline *pipeline)
return;
if (G_UNLIKELY (pipeline->layers_cache != pipeline->short_layers_cache))
g_slice_free1 (sizeof (CoglPipelineLayer *) * pipeline->n_layers,
pipeline->layers_cache);
g_free (pipeline->layers_cache);
pipeline->layers_cache_dirty = TRUE;
_cogl_pipeline_node_foreach_child (COGL_NODE (pipeline),
@ -254,7 +253,7 @@ _cogl_pipeline_revert_weak_ancestors (CoglPipeline *strong)
static CoglPipeline *
_cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak)
{
CoglPipeline *pipeline = g_slice_new (CoglPipeline);
CoglPipeline *pipeline = g_new0 (CoglPipeline, 1);
_cogl_pipeline_node_init (COGL_NODE (pipeline));
@ -393,11 +392,11 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->fragment_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
g_slice_free (CoglPipelineBigState, pipeline->big_state);
g_free (pipeline->big_state);
recursively_free_layer_caches (pipeline);
g_slice_free (CoglPipeline, pipeline);
g_free (pipeline);
}
gboolean
@ -433,7 +432,7 @@ _cogl_pipeline_update_layers_cache (CoglPipeline *pipeline)
else
{
pipeline->layers_cache =
g_slice_alloc0 (sizeof (CoglPipelineLayer *) * n_layers);
g_malloc0 (sizeof (CoglPipelineLayer *) * n_layers);
}
/* Notes:
@ -838,7 +837,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
{
if (!dest->has_big_state)
{
dest->big_state = g_slice_new (CoglPipelineBigState);
dest->big_state = g_new0 (CoglPipelineBigState, 1);
dest->has_big_state = TRUE;
}
big_state = dest->big_state;
@ -1220,7 +1219,7 @@ _cogl_pipeline_pre_change_notify (CoglPipeline *pipeline,
if (change & COGL_PIPELINE_STATE_NEEDS_BIG_STATE &&
!pipeline->has_big_state)
{
pipeline->big_state = g_slice_new (CoglPipelineBigState);
pipeline->big_state = g_new0 (CoglPipelineBigState, 1);
pipeline->has_big_state = TRUE;
}

View File

@ -63,7 +63,7 @@ _cogl_pixel_buffer_new (CoglContext *context,
const void *data,
GError **error)
{
CoglPixelBuffer *pixel_buffer = g_slice_new0 (CoglPixelBuffer);
CoglPixelBuffer *pixel_buffer = g_new0 (CoglPixelBuffer, 1);
CoglBuffer *buffer = COGL_BUFFER (pixel_buffer);
/* parent's constructor */
@ -111,6 +111,6 @@ _cogl_pixel_buffer_free (CoglPixelBuffer *buffer)
/* parent's destructor */
_cogl_buffer_fini (COGL_BUFFER (buffer));
g_slice_free (CoglPixelBuffer, buffer);
g_free (buffer);
}

View File

@ -162,7 +162,7 @@ _cogl_poll_renderer_remove_fd (CoglRenderer *renderer, int fd)
{
renderer->poll_sources =
g_list_delete_link (renderer->poll_sources, l);
g_slice_free (CoglPollSource, source);
g_free (source);
break;
}
}
@ -203,7 +203,7 @@ _cogl_poll_renderer_add_fd (CoglRenderer *renderer,
_cogl_poll_renderer_remove_fd (renderer, fd);
source = g_slice_new0 (CoglPollSource);
source = g_new0 (CoglPollSource, 1);
source->fd = fd;
source->prepare = prepare;
source->dispatch = dispatch;
@ -223,7 +223,7 @@ _cogl_poll_renderer_add_source (CoglRenderer *renderer,
{
CoglPollSource *source;
source = g_slice_new0 (CoglPollSource);
source = g_new0 (CoglPollSource, 1);
source->fd = -1;
source->prepare = prepare;
source->dispatch = dispatch;
@ -246,7 +246,7 @@ _cogl_poll_renderer_remove_source (CoglRenderer *renderer,
{
renderer->poll_sources =
g_list_delete_link (renderer->poll_sources, l);
g_slice_free (CoglPollSource, source);
g_free (source);
break;
}
}

View File

@ -58,8 +58,8 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode,
CoglPrimitive *primitive;
int i;
primitive = g_slice_alloc (sizeof (CoglPrimitive) +
sizeof (CoglAttribute *) * (n_attributes - 1));
primitive = g_malloc0 (sizeof (CoglPrimitive) +
sizeof (CoglAttribute *) * (n_attributes - 1));
primitive->mode = mode;
primitive->first_vertex = 0;
primitive->n_vertices = n_vertices;
@ -384,15 +384,12 @@ _cogl_primitive_free (CoglPrimitive *primitive)
cogl_object_unref (primitive->attributes[i]);
if (primitive->attributes != &primitive->embedded_attribute)
g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes,
primitive->attributes);
g_free (primitive->attributes);
if (primitive->indices)
cogl_object_unref (primitive->indices);
g_slice_free1 (sizeof (CoglPrimitive) +
sizeof (CoglAttribute *) *
(primitive->n_embedded_attributes - 1), primitive);
g_free (primitive);
}
static void
@ -441,17 +438,15 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive,
if (n_attributes <= primitive->n_embedded_attributes)
{
if (primitive->attributes != &primitive->embedded_attribute)
g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes,
primitive->attributes);
g_free (primitive->attributes);
primitive->attributes = &primitive->embedded_attribute;
}
else
{
if (primitive->attributes != &primitive->embedded_attribute)
g_slice_free1 (sizeof (CoglAttribute *) * primitive->n_attributes,
primitive->attributes);
g_free (primitive->attributes);
primitive->attributes =
g_slice_alloc (sizeof (CoglAttribute *) * n_attributes);
g_malloc0 (sizeof (CoglAttribute *) * n_attributes);
}
memcpy (primitive->attributes, attributes,

View File

@ -121,13 +121,13 @@ struct _CoglRectangleMapStackEntry
static CoglRectangleMapNode *
_cogl_rectangle_map_node_new (void)
{
return g_slice_new (CoglRectangleMapNode);
return g_new0 (CoglRectangleMapNode, 1);
}
static void
_cogl_rectangle_map_node_free (CoglRectangleMapNode *node)
{
g_slice_free (CoglRectangleMapNode, node);
g_free (node);
}
CoglRectangleMap *

View File

@ -164,7 +164,7 @@ _cogl_renderer_get_winsys (CoglRenderer *renderer)
static void
native_filter_closure_free (CoglNativeFilterClosure *closure)
{
g_slice_free (CoglNativeFilterClosure, closure);
g_free (closure);
}
static void
@ -652,7 +652,7 @@ _cogl_renderer_add_native_filter (CoglRenderer *renderer,
{
CoglNativeFilterClosure *closure;
closure = g_slice_new (CoglNativeFilterClosure);
closure = g_new0 (CoglNativeFilterClosure, 1);
closure->func = func;
closure->data = data;

View File

@ -181,7 +181,7 @@ _cogl_sampler_cache_get_entry_gl (CoglSamplerCache *cache,
if (entry == NULL)
{
entry = g_slice_dup (CoglSamplerCacheEntry, key);
entry = g_memdup2 (key, sizeof (CoglSamplerCacheEntry));
cache->context->driver_vtable->sampler_init (cache->context, entry);
@ -204,7 +204,7 @@ _cogl_sampler_cache_get_entry_cogl (CoglSamplerCache *cache,
CoglSamplerCacheEntry canonical_key;
CoglSamplerCacheEntry *gl_entry;
entry = g_slice_dup (CoglSamplerCacheEntry, key);
entry = g_memdup2 (key, sizeof (CoglSamplerCacheEntry));
/* Get the sampler object number from the canonical GL version
of the sampler state cache */
@ -271,7 +271,7 @@ hash_table_free_gl_cb (void *key,
context->driver_vtable->sampler_free (context, entry);
g_slice_free (CoglSamplerCacheEntry, entry);
g_free (entry);
}
static void
@ -281,7 +281,7 @@ hash_table_free_cogl_cb (void *key,
{
CoglSamplerCacheEntry *entry = value;
g_slice_free (CoglSamplerCacheEntry, entry);
g_free (entry);
}
void

View File

@ -49,7 +49,7 @@ cogl_snippet_new (CoglSnippetHook hook,
const char *declarations,
const char *post)
{
CoglSnippet *snippet = g_slice_new0 (CoglSnippet);
CoglSnippet *snippet = g_new0 (CoglSnippet, 1);
_cogl_snippet_object_new (snippet);
@ -181,5 +181,5 @@ _cogl_snippet_free (CoglSnippet *snippet)
g_free (snippet->pre);
g_free (snippet->replace);
g_free (snippet->post);
g_slice_free (CoglSnippet, snippet);
g_free (snippet);
}

View File

@ -46,13 +46,13 @@ COGL_GTYPE_DEFINE_CLASS (SwapChain, swap_chain);
static void
_cogl_swap_chain_free (CoglSwapChain *swap_chain)
{
g_slice_free (CoglSwapChain, swap_chain);
g_free (swap_chain);
}
CoglSwapChain *
cogl_swap_chain_new (void)
{
CoglSwapChain *swap_chain = g_slice_new0 (CoglSwapChain);
CoglSwapChain *swap_chain = g_new0 (CoglSwapChain, 1);
swap_chain->length = -1; /* no preference */

View File

@ -155,7 +155,7 @@ _cogl_texture_free_loader (CoglTexture *texture)
cogl_object_unref (loader->src.bitmap.bitmap);
break;
}
g_slice_free (CoglTextureLoader, loader);
g_free (loader);
texture->loader = NULL;
}
}
@ -163,7 +163,7 @@ _cogl_texture_free_loader (CoglTexture *texture)
CoglTextureLoader *
_cogl_texture_create_loader (void)
{
return g_slice_new0 (CoglTextureLoader);
return g_new0 (CoglTextureLoader, 1);
}
void

View File

@ -58,7 +58,7 @@ _xlib_renderer_data_free (CoglXlibRenderer *data)
if (data->xvisinfo)
XFree (data->xvisinfo);
g_slice_free (CoglXlibRenderer, data);
g_free (data);
}
CoglXlibRenderer *
@ -71,7 +71,7 @@ _cogl_xlib_renderer_get_data (CoglRenderer *renderer)
data. */
if (!renderer->custom_winsys_user_data)
renderer->custom_winsys_user_data = g_slice_new0 (CoglXlibRenderer);
renderer->custom_winsys_user_data = g_new0 (CoglXlibRenderer, 1);
return renderer->custom_winsys_user_data;
}

View File

@ -73,7 +73,7 @@ _cogl_program_free (CoglProgram *program)
g_array_free (program->custom_uniforms, TRUE);
g_slice_free (CoglProgram, program);
g_free (program);
}
CoglHandle
@ -81,7 +81,7 @@ cogl_create_program (void)
{
CoglProgram *program;
program = g_slice_new0 (CoglProgram);
program = g_new0 (CoglProgram, 1);
program->custom_uniforms =
g_array_new (FALSE, FALSE, sizeof (CoglProgramUniform));

View File

@ -54,7 +54,7 @@ _cogl_shader_free (CoglShader *shader)
if (shader->gl_handle)
GE (ctx, glDeleteShader (shader->gl_handle));
g_slice_free (CoglShader, shader);
g_free (shader);
}
CoglHandle
@ -75,7 +75,7 @@ cogl_create_shader (CoglShaderType type)
return NULL;
}
shader = g_slice_new (CoglShader);
shader = g_new0 (CoglShader, 1);
shader->gl_handle = 0;
shader->compilation_pipeline = NULL;
shader->type = type;

View File

@ -232,13 +232,13 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
* sizeof (options) != 0)
* {
* cogl_object_unref (overrides->weak_pipeline);
* g_slice_free (Overrides, overrides);
* g_free (overrides);
* overrides = NULL;
* }
* }
* if (!overrides)
* {
* overrides = g_slice_new (Overrides);
* overrides = g_new0 (Overrides, 1);
* overrides->weak_pipeline =
* cogl_pipeline_weak_copy (pipeline);
* _cogl_pipeline_apply_overrides (overrides->weak_pipeline,

View File

@ -113,7 +113,7 @@ shader_state_new (int n_layers,
{
CoglPipelineShaderState *shader_state;
shader_state = g_slice_new0 (CoglPipelineShaderState);
shader_state = g_new0 (CoglPipelineShaderState, 1);
shader_state->ref_count = 1;
shader_state->unit_state = g_new0 (UnitState, n_layers);
shader_state->cache_entry = cache_entry;
@ -146,7 +146,7 @@ destroy_shader_state (void *user_data,
g_free (shader_state->unit_state);
g_slice_free (CoglPipelineShaderState, shader_state);
g_free (shader_state);
}
}
@ -869,7 +869,7 @@ ensure_layer_generated (CoglPipeline *pipeline,
layer_index,
layer_index);
g_slice_free (LayerData, layer_data);
g_free (layer_data);
}
static gboolean
@ -884,7 +884,7 @@ _cogl_pipeline_fragend_glsl_add_layer (CoglPipeline *pipeline,
return TRUE;
/* Store the layers in reverse order */
layer_data = g_slice_new (LayerData);
layer_data = g_new0 (LayerData, 1);
layer_data->layer = layer;
if (_cogl_list_empty (&shader_state->layers))
@ -1016,7 +1016,7 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
tmp,
&shader_state->layers,
link)
g_slice_free (LayerData, layer_data);
g_free (layer_data);
}
else
g_string_append (shader_state->source,

View File

@ -231,7 +231,7 @@ program_state_new (int n_layers,
{
CoglPipelineProgramState *program_state;
program_state = g_slice_new (CoglPipelineProgramState);
program_state = g_new0 (CoglPipelineProgramState, 1);
program_state->ref_count = 1;
program_state->program = 0;
program_state->unit_state = g_new (UnitState, n_layers);
@ -278,7 +278,7 @@ destroy_program_state (void *user_data,
if (program_state->uniform_locations)
g_array_free (program_state->uniform_locations, TRUE);
g_slice_free (CoglPipelineProgramState, program_state);
g_free (program_state);
}
}

View File

@ -68,7 +68,7 @@ shader_state_new (CoglPipelineCacheEntry *cache_entry)
{
CoglPipelineShaderState *shader_state;
shader_state = g_slice_new0 (CoglPipelineShaderState);
shader_state = g_new0 (CoglPipelineShaderState, 1);
shader_state->ref_count = 1;
shader_state->cache_entry = cache_entry;
@ -98,7 +98,7 @@ destroy_shader_state (void *user_data,
if (shader_state->gl_shader)
GE( ctx, glDeleteShader (shader_state->gl_shader) );
g_slice_free (CoglPipelineShaderState, shader_state);
g_free (shader_state);
}
}

View File

@ -193,7 +193,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
eglTerminate (egl_renderer->edpy);
g_slice_free (CoglRendererEGL, egl_renderer);
g_free (egl_renderer);
}
static EGLDisplay
@ -236,7 +236,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
CoglRendererEGL *egl_renderer;
CoglXlibRenderer *xlib_renderer;
renderer->winsys = g_slice_new0 (CoglRendererEGL);
renderer->winsys = g_new0 (CoglRendererEGL, 1);
egl_renderer = renderer->winsys;
xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
@ -303,7 +303,7 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
CoglDisplayEGL *egl_display = display->winsys;
CoglDisplayXlib *xlib_display;
xlib_display = g_slice_new0 (CoglDisplayXlib);
xlib_display = g_new0 (CoglDisplayXlib, 1);
egl_display->platform = xlib_display;
return TRUE;
@ -314,7 +314,7 @@ _cogl_winsys_egl_display_destroy (CoglDisplay *display)
{
CoglDisplayEGL *egl_display = display->winsys;
g_slice_free (CoglDisplayXlib, egl_display->platform);
g_free (egl_display->platform);
}
static gboolean

View File

@ -481,7 +481,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
if (egl_renderer->platform_vtable->display_destroy)
egl_renderer->platform_vtable->display_destroy (display);
g_slice_free (CoglDisplayEGL, display->winsys);
g_free (display->winsys);
display->winsys = NULL;
}
@ -495,7 +495,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
g_return_val_if_fail (display->winsys == NULL, FALSE);
egl_display = g_slice_new0 (CoglDisplayEGL);
egl_display = g_new0 (CoglDisplayEGL, 1);
display->winsys = egl_display;
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT

View File

@ -307,7 +307,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
if (glx_renderer->libgl_module)
g_module_close (glx_renderer->libgl_module);
g_slice_free (CoglGLXRenderer, renderer->winsys);
g_free (renderer->winsys);
}
static gboolean
@ -440,7 +440,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
CoglGLXRenderer *glx_renderer;
CoglXlibRenderer *xlib_renderer;
renderer->winsys = g_slice_new0 (CoglGLXRenderer);
renderer->winsys = g_new0 (CoglGLXRenderer, 1);
glx_renderer = renderer->winsys;
xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
@ -879,7 +879,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
glx_display->dummy_xwin = None;
}
g_slice_free (CoglGLXDisplay, display->winsys);
g_free (display->winsys);
display->winsys = NULL;
}
@ -892,7 +892,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
g_return_val_if_fail (display->winsys == NULL, FALSE);
glx_display = g_slice_new0 (CoglGLXDisplay);
glx_display = g_new0 (CoglGLXDisplay, 1);
display->winsys = glx_display;
if (!create_context (display, error))