PERFORCE change 122033 for review
Andrew Turner
andrew at FreeBSD.org
Wed Jun 20 11:49:48 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122033
Change 122033 by andrew at 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) {
/*
More information about the p4-projects
mailing list