[librsvg: 1/3] drawing_ctx: refactor functions to manipulate list of acquired node
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/3] drawing_ctx: refactor functions to manipulate list of acquired node
- Date: Fri, 15 Jun 2018 02:36:16 +0000 (UTC)
commit 1b9f3c9d56ad935ccdc6bb93727941196eb42dc1
Author: Paolo Borelli <pborelli gnome org>
Date: Thu Jun 14 21:04:22 2018 +0200
drawing_ctx: refactor functions to manipulate list of acquired node
librsvg/rsvg-drawing-ctx.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/librsvg/rsvg-drawing-ctx.c b/librsvg/rsvg-drawing-ctx.c
index ef686a93..eda8b82a 100644
--- a/librsvg/rsvg-drawing-ctx.c
+++ b/librsvg/rsvg-drawing-ctx.c
@@ -208,6 +208,24 @@ rsvg_drawing_ctx_pop_cr (RsvgDrawingCtx *ctx)
ctx->cr_stack = g_list_delete_link (ctx->cr_stack, ctx->cr_stack);
}
+static gboolean
+rsvg_drawing_ctx_prepend_acquired_node (RsvgDrawingCtx *ctx,
+ RsvgNode *node)
+{
+ if (!g_slist_find (ctx->acquired_nodes, node)) {
+ ctx->acquired_nodes = g_slist_prepend (ctx->acquired_nodes, node);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+rsvg_drawing_ctx_remove_acquired_node (RsvgDrawingCtx *ctx, RsvgNode *node)
+{
+ ctx->acquired_nodes = g_slist_remove (ctx->acquired_nodes, node);
+}
+
/*
* rsvg_drawing_ctx_acquire_node:
* @ctx: The drawing context in use
@@ -239,12 +257,11 @@ rsvg_drawing_ctx_acquire_node (RsvgDrawingCtx *ctx, const char *url)
if (node == NULL)
return NULL;
- if (g_slist_find (ctx->acquired_nodes, node))
- return NULL;
-
- ctx->acquired_nodes = g_slist_prepend (ctx->acquired_nodes, node);
+ if (rsvg_drawing_ctx_prepend_acquired_node (ctx, node)) {
+ return node;
+ }
- return node;
+ return NULL;
}
/*
@@ -266,7 +283,7 @@ rsvg_drawing_ctx_release_node (RsvgDrawingCtx *ctx, RsvgNode *node)
g_return_if_fail (ctx->acquired_nodes != NULL);
g_return_if_fail (ctx->acquired_nodes->data == node);
- ctx->acquired_nodes = g_slist_remove (ctx->acquired_nodes, node);
+ rsvg_drawing_ctx_remove_acquired_node (ctx, node);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]