[librsvg/librsvg-2.42: 4/8] Extract rsvg_drawing_ctx_acquire_node_ref() like in newer branches



commit 58f4a90031bbe5c96bdc6a5e3993ecb56afbb8c4
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 25 11:07:34 2020 -0600

    Extract rsvg_drawing_ctx_acquire_node_ref() like in newer branches

 librsvg/rsvg-base.c    | 21 ++++++++++++---------
 librsvg/rsvg-private.h |  2 ++
 2 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/librsvg/rsvg-base.c b/librsvg/rsvg-base.c
index 039fbf9e..8b8ba25d 100644
--- a/librsvg/rsvg-base.c
+++ b/librsvg/rsvg-base.c
@@ -1676,6 +1676,17 @@ limits_exceeded (RsvgDrawingCtx *draw_ctx)
     return draw_ctx->num_elements_acquired > 500000;
 }
 
+RsvgNode *
+rsvg_drawing_ctx_acquire_node_ref (RsvgDrawingCtx * ctx, RsvgNode *node)
+{
+  if (g_slist_find (ctx->acquired_nodes, node))
+    return NULL;
+
+  ctx->acquired_nodes = g_slist_prepend (ctx->acquired_nodes, node);
+
+  return node;
+}
+
 /*
  * rsvg_drawing_ctx_acquire_node:
  * @ctx: The drawing context in use
@@ -1711,12 +1722,7 @@ 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);
-
-  return node;
+  return rsvg_drawing_ctx_acquire_node_ref (ctx, node);
 }
 
 /**
@@ -1773,9 +1779,6 @@ rsvg_drawing_ctx_release_node (RsvgDrawingCtx * ctx, RsvgNode *node)
   if (node == NULL)
     return;
 
-  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);
 }
 
diff --git a/librsvg/rsvg-private.h b/librsvg/rsvg-private.h
index 340d1c8a..c9aba05e 100644
--- a/librsvg/rsvg-private.h
+++ b/librsvg/rsvg-private.h
@@ -502,6 +502,8 @@ RsvgNode *rsvg_drawing_ctx_acquire_node         (RsvgDrawingCtx * ctx, const cha
 G_GNUC_INTERNAL
 RsvgNode *rsvg_drawing_ctx_acquire_node_of_type (RsvgDrawingCtx * ctx, const char *url, RsvgNodeType type);
 G_GNUC_INTERNAL
+RsvgNode *rsvg_drawing_ctx_acquire_node_ref     (RsvgDrawingCtx * ctx, RsvgNode *node);
+G_GNUC_INTERNAL
 void rsvg_drawing_ctx_release_node              (RsvgDrawingCtx * ctx, RsvgNode *node);
 
 G_GNUC_INTERNAL


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]