X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c.c;h=291c43085a5ec4b10191f68c9cf5d4dfe7f843bb;hp=600440c92966ef54c2999eb2c4bf652644e3a226;hb=b4d2a01828e5de85e5eee3631f7fe3925a0312ca;hpb=99f68f259f92eee884c6c7396f61b9c16e2bf354 diff --git a/ocaml/guestfs_c.c b/ocaml/guestfs_c.c index 600440c..291c430 100644 --- a/ocaml/guestfs_c.c +++ b/ocaml/guestfs_c.c @@ -119,3 +119,29 @@ ocaml_guestfs_close (value gv) CAMLreturn (Val_unit); } + +/* Copy string array value. */ +char ** +ocaml_guestfs_strings_val (value sv) +{ + CAMLparam1 (sv); + char **r; + int i; + + r = malloc (sizeof (char *) * (Wosize_val (sv) + 1)); + for (i = 0; i < Wosize_val (sv); ++i) + r[i] = String_val (Field (sv, i)); + r[i] = NULL; + + CAMLreturnT (char **, r); +} + +/* Free array of strings. */ +void +ocaml_guestfs_free_strings (char **argv) +{ + /* Don't free the actual strings - they are String_vals on + * the OCaml heap. + */ + free (argv); +}