From 65b673e50fd5fa397b1a5e227a4206fc74f7462c Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Fri, 7 Jul 2000 01:25:26 +0200
Subject: [PATCH] Added some do_free_* functions and made them accept a zero
 argument.

Rev: src/array.c:1.75
Rev: src/mapping.c:1.91
Rev: src/mapping.h:1.26
Rev: src/multiset.c:1.23
Rev: src/multiset.h:1.12
Rev: src/object.c:1.132
Rev: src/stralloc.c:1.84
---
 src/array.c    | 5 +++--
 src/mapping.c  | 8 +++++++-
 src/mapping.h  | 3 ++-
 src/multiset.c | 8 +++++++-
 src/multiset.h | 3 ++-
 src/object.c   | 5 +++--
 src/stralloc.c | 5 +++--
 7 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/array.c b/src/array.c
index ccfbf4c355..dd69f7c72f 100644
--- a/src/array.c
+++ b/src/array.c
@@ -23,7 +23,7 @@
 #include "stuff.h"
 #include "bignum.h"
 
-RCSID("$Id: array.c,v 1.74 2000/07/04 00:43:56 mast Exp $");
+RCSID("$Id: array.c,v 1.75 2000/07/06 23:25:25 mast Exp $");
 
 struct array empty_array=
 {
@@ -129,7 +129,8 @@ void really_free_array(struct array *v)
 
 void do_free_array(struct array *a)
 {
-  free_array(a);
+  if (a)
+    free_array(a);
 }
 
 /*
diff --git a/src/mapping.c b/src/mapping.c
index ce79e7a213..b43d44273d 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: mapping.c,v 1.90 2000/07/04 00:43:57 mast Exp $");
+RCSID("$Id: mapping.c,v 1.91 2000/07/06 23:25:26 mast Exp $");
 #include "main.h"
 #include "object.h"
 #include "mapping.h"
@@ -210,6 +210,12 @@ void really_free_mapping_data(struct mapping_data *md)
   free((char *) md);
 }
 
+void do_free_mapping(struct mapping *m)
+{
+  if (m)
+    free_mapping(m);
+}
+
 /* This function is used to rehash a mapping without loosing the internal
  * order in each hash chain. This is to prevent mappings from becoming
  * inefficient just after being rehashed.
diff --git a/src/mapping.h b/src/mapping.h
index 0959bf2016..0bd51726ba 100644
--- a/src/mapping.h
+++ b/src/mapping.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: mapping.h,v 1.25 2000/06/09 22:43:05 mast Exp $
+ * $Id: mapping.h,v 1.26 2000/07/06 23:25:26 mast Exp $
  */
 #ifndef MAPPING_H
 #define MAPPING_H
@@ -80,6 +80,7 @@ BLOCK_ALLOC(mapping, 511)
 
 struct mapping *debug_allocate_mapping(int size);
 void really_free_mapping_data(struct mapping_data *md);
+void do_free_mapping(struct mapping *m);
 struct mapping_data *copy_mapping_data(struct mapping_data *md);
 void mapping_fix_type_field(struct mapping *m);
 void low_mapping_insert(struct mapping *m,
diff --git a/src/multiset.c b/src/multiset.c
index 8722c1cb8f..98bc4392a9 100644
--- a/src/multiset.c
+++ b/src/multiset.c
@@ -16,7 +16,7 @@
 #include "gc.h"
 #include "security.h"
 
-RCSID("$Id: multiset.c,v 1.22 2000/06/09 22:43:04 mast Exp $");
+RCSID("$Id: multiset.c,v 1.23 2000/07/06 23:25:26 mast Exp $");
 
 struct multiset *first_multiset;
 
@@ -70,6 +70,12 @@ void really_free_multiset(struct multiset *l)
   GC_FREE();
 }
 
+void do_free_multiset(struct multiset *l)
+{
+  if (l)
+    free_multiset(l);
+}
+
 
 void order_multiset(struct multiset *l)
 {
diff --git a/src/multiset.h b/src/multiset.h
index cb34d87225..85bb71b1a6 100644
--- a/src/multiset.h
+++ b/src/multiset.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: multiset.h,v 1.11 2000/06/09 22:43:04 mast Exp $
+ * $Id: multiset.h,v 1.12 2000/07/06 23:25:26 mast Exp $
  */
 #ifndef MULTISET_H
 #define MULTISET_H
@@ -33,6 +33,7 @@ extern struct multiset *gc_internal_multiset;
 int multiset_member(struct multiset *l, struct svalue *ind);
 struct multiset *allocate_multiset(struct array *ind);
 void really_free_multiset(struct multiset *l);
+void do_free_multiset(struct multiset *l);
 void order_multiset(struct multiset *l);
 struct multiset *mkmultiset(struct array *ind);
 void multiset_insert(struct multiset *l,
diff --git a/src/object.c b/src/object.c
index 1a80fa5e46..010142b703 100644
--- a/src/object.c
+++ b/src/object.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: object.c,v 1.131 2000/07/04 00:43:57 mast Exp $");
+RCSID("$Id: object.c,v 1.132 2000/07/06 23:25:26 mast Exp $");
 #include "object.h"
 #include "dynamic_buffer.h"
 #include "interpret.h"
@@ -252,7 +252,8 @@ static void call_pike_initializers(struct object *o, int args)
 
 void do_free_object(struct object *o)
 {
-  free_object(o);
+  if (o)
+    free_object(o);
 }
 
 struct object *debug_clone_object(struct program *p, int args)
diff --git a/src/stralloc.c b/src/stralloc.c
index 735f189f90..047f0eef84 100644
--- a/src/stralloc.c
+++ b/src/stralloc.c
@@ -25,7 +25,7 @@
 #define HUGE HUGE_VAL
 #endif /*!HUGE*/
 
-RCSID("$Id: stralloc.c,v 1.83 2000/06/27 15:24:34 grubba Exp $");
+RCSID("$Id: stralloc.c,v 1.84 2000/07/06 23:25:26 mast Exp $");
 
 #define BEGIN_HASH_SIZE 997
 #define MAX_AVG_LINK_LENGTH 3
@@ -712,7 +712,8 @@ void unlink_pike_string(struct pike_string *s)
 
 void do_free_string(struct pike_string *s)
 {
-  free_string(s);
+  if (s)
+    free_string(s);
 }
 
 void really_free_string(struct pike_string *s)
-- 
GitLab