Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jun 2007 11:49:47 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 122033 for review
Message-ID:  <200706201149.l5KBnlUM062566@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122033

Change 122033 by andrew@andrew_hermies on 2007/06/20 11:49:02

	Add facund_object_free to free memory used by objects

Affected files ...

.. //depot/projects/soc2007/andrew-update/lib/facund_object.c#3 edit
.. //depot/projects/soc2007/andrew-update/lib/facund_object.h#2 edit
.. //depot/projects/soc2007/andrew-update/lib/facund_server.c#7 edit

Differences ...

==== //depot/projects/soc2007/andrew-update/lib/facund_object.c#3 (text+ko) ====

@@ -292,6 +292,30 @@
 	return obj->obj_array[pos];
 }
 
+/*
+ * Free an object and it's children
+ */
+void
+facund_object_free(struct facund_object *obj)
+{
+	if (obj == NULL)
+		return;
+
+	if (obj->obj_string != NULL)
+		free(obj->obj_string);
+
+	if (obj->obj_array != NULL) {
+		unsigned int i;
+
+		for (i = 0; obj->obj_array[i] != NULL; i++) {
+			facund_object_free(obj->obj_array[i]);
+		}
+		free(obj->obj_array);
+	}
+
+	free(obj);
+}
+
 struct facund_object *
 facund_object_new_from_typestr(const char *type)
 {

==== //depot/projects/soc2007/andrew-update/lib/facund_object.h#2 (text+ko) ====

@@ -72,6 +72,8 @@
 const struct facund_object *facund_object_get_array_item(struct facund_object *,
 			    unsigned int);
 
+void			 facund_object_free(struct facund_object *);
+
 struct facund_object	*facund_object_new_from_typestr(const char *);
 int			 facund_object_set_from_str(struct facund_object *,
 			    const char *);

==== //depot/projects/soc2007/andrew-update/lib/facund_server.c#7 (text+ko) ====

@@ -211,7 +211,7 @@
 		    conn->call_arg);
 		conn->current_call[0] = '\0';
 		conn->call_id[0] = '\0';
-		/* TODO: Free the call_arg */
+		facund_object_free(conn->call_arg);
 		conn->call_arg = NULL;
 	} else if (strcmp(name, "data") == 0) {
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706201149.l5KBnlUM062566>