summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Jerram <neil@ossau.uklinux.net>2005-11-17 18:50:01 +0000
committerNeil Jerram <neil@ossau.uklinux.net>2005-11-17 18:50:01 +0000
commitdbb5de29496c2da4a285255c951364a97600c5ba (patch)
tree8972287466a285ef49864de3d7a94661baae9a3d
parent3f98874a963607cf8f0bc50a78dcd3f85037bf44 (diff)
downloadguile-dbb5de29496c2da4a285255c951364a97600c5ba.tar.gz
* print.c (EXIT_NESTED_DATA): Before popping from the stack, reset
the value at its top. This fixes a reference leak. (PUSH_REF): Perform `pstate->top++' after calling `PSTATE_STACK_SET ()' in order to avoid undesired potential side effects.
-rw-r--r--libguile/ChangeLog8
-rw-r--r--libguile/print.c51
2 files changed, 38 insertions, 21 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 52c7066f1..0ea694064 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,11 @@
+2005-11-17 Ludovic Courtès <ludovic.courtes@laas.fr>
+
+ * print.c (EXIT_NESTED_DATA): Before popping from the stack, reset
+ the value at its top. This fixes a reference leak.
+ (PUSH_REF): Perform `pstate->top++' after calling
+ `PSTATE_STACK_SET ()' in order to avoid undesired potential side
+ effects.
+
2005-11-12 Ludovic Courtès <ludovic.courtes@laas.fr>
* gc.c (scm_weak_vectors): Removed.
diff --git a/libguile/print.c b/libguile/print.c
index 43b71654d..cdeb0c41d 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -112,31 +112,40 @@ SCM_DEFINE (scm_print_options, "print-options-interface", 0, 1, 0,
* time complexity (O (depth * N)), The printer code can be
* rewritten to be O(N).
*/
-#define PUSH_REF(pstate, obj) \
-do { \
- PSTATE_STACK_SET (pstate, pstate->top++, obj); \
- if (pstate->top == pstate->ceiling) \
- grow_ref_stack (pstate); \
+#define PUSH_REF(pstate, obj) \
+do \
+{ \
+ PSTATE_STACK_SET (pstate, pstate->top, obj); \
+ pstate->top++; \
+ if (pstate->top == pstate->ceiling) \
+ grow_ref_stack (pstate); \
} while(0)
-#define ENTER_NESTED_DATA(pstate, obj, label) \
-do { \
- register unsigned long i; \
- for (i = 0; i < pstate->top; ++i) \
- if (scm_is_eq (PSTATE_STACK_REF (pstate, i), (obj))) \
- goto label; \
- if (pstate->fancyp) \
- { \
- if (pstate->top - pstate->list_offset >= pstate->level) \
- { \
- scm_putc ('#', port); \
- return; \
- } \
- } \
- PUSH_REF(pstate, obj); \
+#define ENTER_NESTED_DATA(pstate, obj, label) \
+do \
+{ \
+ register unsigned long i; \
+ for (i = 0; i < pstate->top; ++i) \
+ if (scm_is_eq (PSTATE_STACK_REF (pstate, i), (obj))) \
+ goto label; \
+ if (pstate->fancyp) \
+ { \
+ if (pstate->top - pstate->list_offset >= pstate->level) \
+ { \
+ scm_putc ('#', port); \
+ return; \
+ } \
+ } \
+ PUSH_REF(pstate, obj); \
} while(0)
-#define EXIT_NESTED_DATA(pstate) { --pstate->top; }
+#define EXIT_NESTED_DATA(pstate) \
+do \
+{ \
+ --pstate->top; \
+ PSTATE_STACK_SET (pstate, pstate->top, SCM_UNDEFINED); \
+} \
+while (0)
SCM scm_print_state_vtable = SCM_BOOL_F;
static SCM print_state_pool = SCM_EOL;