* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "guestfs_c.h"
+/* This macro was added in OCaml 3.10. Backport for earlier versions. */
+#ifndef CAMLreturnT
+#define CAMLreturnT(type, result) do{ \
+ type caml__temp_result = (result); \
+ caml_local_roots = caml__frame; \
+ return (caml__temp_result); \
+}while(0)
+#endif
+
+/* These prototypes are solely to quiet gcc warning. */
+CAMLprim value ocaml_guestfs_create (void);
+CAMLprim value ocaml_guestfs_close (value gv);
+
/* Allocate handles and deal with finalization. */
static void
guestfs_finalize (value gv)
}
static struct custom_operations guestfs_custom_operations = {
- "guestfs_custom_operations",
+ (char *) "guestfs_custom_operations",
guestfs_finalize,
custom_compare_default,
custom_hash_default,
CAMLnoreturn;
}
+void
+ocaml_guestfs_raise_closed (const char *func)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (v);
+
+ v = caml_copy_string (func);
+ caml_raise_with_arg (*caml_named_value ("ocaml_guestfs_closed"), v);
+ CAMLnoreturn;
+}
+
/* Guestfs.create */
CAMLprim value
ocaml_guestfs_create (void)
{
CAMLparam1 (sv);
char **r;
- int i;
+ unsigned int i;
r = guestfs_safe_malloc (g, sizeof (char *) * (Wosize_val (sv) + 1));
for (i = 0; i < Wosize_val (sv); ++i)