From: "Richard W.M. Jones" <rjones(a)redhat.com>
This is just code motion.
---
.gitignore | 1 +
generator/c.ml | 69 +++++++++++++++++++++++++++++++++----------------------
generator/main.ml | 1 +
po/POTFILES | 1 +
src/Makefile.am | 2 ++
5 files changed, 47 insertions(+), 27 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5b91286..b3c9ef7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -346,6 +346,7 @@ Makefile.in
/src/errnostring-gperf.c
/src/errnostring-gperf.gperf
/src/errnostring.h
+/src/free-structs.c
/src/guestfs.3
/src/guestfs-actions.pod
/src/guestfs-availability.pod
diff --git a/generator/c.ml b/generator/c.ml
index ac8fd5e..484b4f9 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -687,6 +687,48 @@ and generate_internal_actions_h () =
c_name style
) non_daemon_functions
+(* Functions to free structures. *)
+and generate_client_free_structs () =
+ generate_header CStyle LGPLv2plus;
+
+ pr "\
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include \"guestfs.h\"
+#include \"guestfs-internal.h\"
+#include \"guestfs_protocol.h\"
+
+";
+
+ pr "/* Structure-freeing functions. These rely on the fact that the\n";
+ pr " * structure format is identical to the XDR format. See note in\n";
+ pr " * generator.ml.\n";
+ pr " */\n";
+ pr "\n";
+
+ List.iter (
+ fun (typ, _) ->
+ pr "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 "}\n";
+ pr "\n";
+
+ pr "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 "}\n";
+ pr "\n";
+
+ ) structs
+
(* Generate the client-side dispatch stubs. *)
and generate_client_actions () =
generate_header CStyle LGPLv2plus;
@@ -1425,33 +1467,6 @@ trace_send_line (guestfs_h *g)
fun f -> generate_daemon_stub f
) daemon_functions;
- (* Functions to free structures. *)
- pr "/* Structure-freeing functions. These rely on the fact that the\n";
- pr " * structure format is identical to the XDR format. See note in\n";
- pr " * generator.ml.\n";
- pr " */\n";
- pr "\n";
-
- List.iter (
- fun (typ, _) ->
- pr "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 "}\n";
- pr "\n";
-
- pr "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 "}\n";
- pr "\n";
-
- ) structs;
-
(* Functions which have optional arguments have two or three
* generated variants.
*)
diff --git a/generator/main.ml b/generator/main.ml
index 4cb3c7c..8d60850 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -84,6 +84,7 @@ Run it from the top source directory using the command
output_to "src/guestfs.h" generate_guestfs_h;
output_to "src/guestfs-internal-actions.h" generate_internal_actions_h;
output_to "src/actions.c" generate_client_actions;
+ output_to "src/free-structs.c" generate_client_free_structs;
output_to "src/bindtests.c" generate_bindtests;
output_to "src/guestfs-structs.pod" generate_structs_pod;
output_to "src/guestfs-actions.pod" generate_actions_pod;
diff --git a/po/POTFILES b/po/POTFILES
index a73377d..3f49a05 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -225,6 +225,7 @@ src/errnostring.c
src/events.c
src/file.c
src/filearch.c
+src/free-structs.c
src/fuse.c
src/guestfs.c
src/info.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f80bc1..082c122 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,6 +28,7 @@ generator_built = \
errnostring-gperf.gperf \
errnostring.c \
errnostring.h \
+ free-structs.c \
guestfs-actions.pod \
guestfs-availability.pod \
guestfs-structs.pod \
@@ -130,6 +131,7 @@ libguestfs_la_SOURCES = \
events.c \
file.c \
filearch.c \
+ free-structs.c \
fuse.c \
info.c \
inspect.c \
--
1.7.11.4