lib: Allow guestfs_free_* functions to be safely called with a NULL pointer.

This is so they work just like 'free'.
This commit is contained in:
Richard W.M. Jones
2013-02-08 13:53:33 +00:00
parent 7b7cfa62e3
commit 5e770c8f6a

View File

@@ -806,16 +806,21 @@ and generate_client_free_structs () =
pr "GUESTFS_DLL_PUBLIC void\n";
pr "guestfs_free_%s (struct guestfs_%s *x)\n" typ typ;
pr "{\n";
pr " xdr_free ((xdrproc_t) xdr_guestfs_int_%s, (char *) x);\n" typ;
pr " free (x);\n";
pr " if (x) {\n";
pr " xdr_free ((xdrproc_t) xdr_guestfs_int_%s, (char *) x);\n" typ;
pr " free (x);\n";
pr " }\n";
pr "}\n";
pr "\n";
pr "GUESTFS_DLL_PUBLIC void\n";
pr "guestfs_free_%s_list (struct guestfs_%s_list *x)\n" typ typ;
pr "{\n";
pr " xdr_free ((xdrproc_t) xdr_guestfs_int_%s_list, (char *) x);\n" typ;
pr " free (x);\n";
pr " if (x) {\n";
pr " xdr_free ((xdrproc_t) xdr_guestfs_int_%s_list, (char *) x);\n"
typ;
pr " free (x);\n";
pr " }\n";
pr "}\n";
pr "\n";