Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 0/7] lib: Stop exporting the safe_malloc, etc. functions.
The safe_malloc (etc) functions call g->abort_fn on failure. That's not appropriate for language bindings, and we never intended that these internal functions be used from language bindings, that was just a historical accident. This patch series removes any external use of the safe_* functions. Rich.
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 1/7] java: Fix documentation of @throws.
The javadoc @throws directive requires a string documenting
when the exception is thrown.
---
generator/java.ml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/generator/java.ml b/generator/java.ml
index 9bc0a24..08e3a5f 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -77,7 +77,7 @@ public class GuestFS {
/**
* Create a libguestfs handle, setting flags.
*
- * @throws LibGuestFSException
+ * @throws LibGuestFSException If there is a libguestfs error.
*/
public GuestFS (Map<String, Object> optargs) throws LibGuestFSException
{
@@ -101,7 +101,7 @@ public class GuestFS {
/**
* Create a libguestfs handle.
*
- * @throws LibGuestFSException
+ * @throws LibGuestFSException If there is a libguestfs error.
*/
public GuestFS () throws LibGuestFSException
{
@@ -121,7 +121,7 @@ public class GuestFS {
* exception.
* </p>
*
- * @throws LibGuestFSException
+ * @throws LibGuestFSException If there is a libguestfs error.
*/
public void close () throws LibGuestFSException
{
@@ -198,7 +198,7 @@ public class GuestFS {
* the libguestfs handle is closed.
* </p>
*
- * @throws LibGuestFSException
+ * @throws LibGuestFSException If there is a libguestfs error.
* @see \"The section "EVENTS" in the guestfs(3)
manual\"
* @see #delete_event_callback
* @return handle for the event
@@ -228,7 +228,7 @@ public class GuestFS {
* libguestfs handle is closed.
* </p>
*
- * @throws LibGuestFSException
+ * @throws LibGuestFSException If there is a libguestfs error.
* @see #set_event_callback
*/
public void delete_event_callback (int eh)
@@ -282,7 +282,7 @@ public class GuestFS {
| { deprecated_by = Some alt } ->
pr " * @deprecated In new code, use {@link #%s}
instead\n" alt
);
- pr " * @throws LibGuestFSException\n";
+ pr " * @throws LibGuestFSException If there is a libguestfs
error.\n";
pr " */\n";
);
pr " ";
--
2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 2/7] ocaml: Stop using the safe_malloc, etc. functions.
---
generator/ocaml.ml | 35 +++++++++++++++++++++++------------
ocaml/guestfs-c.c | 15 ++++++++++-----
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/generator/ocaml.ml b/generator/ocaml.ml
index 1447bdc..9071eb0 100644
--- a/generator/ocaml.ml
+++ b/generator/ocaml.ml
@@ -592,14 +592,23 @@ copy_table (char * const * argv)
| Key n
| GUID n ->
(* Copy strings in case the GC moves them: RHBZ#604691 *)
- pr " char *%s = guestfs_int_safe_strdup (g, String_val
(%sv));\n" n n
+ pr " char *%s;\n" n;
+ pr " %s = strdup (String_val (%sv));\n" n n;
+ pr " if (%s == NULL) caml_raise_out_of_memory ();\n" n
| OptString n ->
- pr " char *%s =\n" n;
- pr " %sv != Val_int (0) ?\n" n;
- pr " guestfs_int_safe_strdup (g, String_val (Field (%sv,
0))) : NULL;\n" n
+ pr " char *%s;\n" n;
+ pr " if (%sv == Val_int (0))\n" n;
+ pr " %s = NULL;\n" n;
+ pr " else {\n";
+ pr " %s = strdup (String_val (Field (%sv, 0)));\n" n
n;
+ pr " if (%s == NULL) caml_raise_out_of_memory ();\n"
n;
+ pr " }\n"
| BufferIn n ->
pr " size_t %s_size = caml_string_length (%sv);\n" n n;
- pr " char *%s = guestfs_int_safe_memdup (g, String_val (%sv),
%s_size);\n" n n n
+ pr " char *%s;\n" n;
+ pr " %s = malloc (%s_size);\n" n n;
+ pr " if (%s == NULL) caml_raise_out_of_memory ();\n" n;
+ pr " memcpy (%s, String_val (%sv), %s_size);\n" n n n
| StringList n | DeviceList n | FilenameList n ->
pr " char **%s = guestfs_int_ocaml_strings_val (g,
%sv);\n" n n
| Bool n ->
@@ -622,17 +631,19 @@ copy_table (char * const * argv)
let uc_n = String.uppercase n in
pr " if (%sv != Val_int (0)) {\n" n;
pr " optargs_s.bitmask |= %s_%s_BITMASK;\n"
c_optarg_prefix uc_n;
- pr " optargs_s.%s = " n;
(match argt with
- | OBool _ -> pr "Bool_val (Field (%sv, 0))" n
- | OInt _ -> pr "Int_val (Field (%sv, 0))" n
- | OInt64 _ -> pr "Int64_val (Field (%sv, 0))" n
+ | OBool _ ->
+ pr " optargs_s.%s = Bool_val (Field (%sv, 0));\n"
n n
+ | OInt _ ->
+ pr " optargs_s.%s = Int_val (Field (%sv, 0));\n" n
n
+ | OInt64 _ ->
+ pr " optargs_s.%s = Int64_val (Field (%sv, 0));\n"
n n
| OString _ ->
- pr "guestfs_int_safe_strdup (g, String_val (Field (%sv,
0)))" n
+ pr " optargs_s.%s = strdup (String_val (Field (%sv,
0)));\n" n n;
+ pr " if (optargs_s.%s == NULL)
caml_raise_out_of_memory ();\n" n
| OStringList n ->
- pr "guestfs_int_ocaml_strings_val (g, Field (%sv,
0))\n" n
+ pr " optargs_s.%s = guestfs_int_ocaml_strings_val (g,
Field (%sv, 0));\n" n n
);
- pr ";\n";
pr " }\n";
) optargs
);
diff --git a/ocaml/guestfs-c.c b/ocaml/guestfs-c.c
index 8f74c21..edb4646 100644
--- a/ocaml/guestfs-c.c
+++ b/ocaml/guestfs-c.c
@@ -193,9 +193,12 @@ guestfs_int_ocaml_strings_val (guestfs_h *g, value sv)
char **r;
size_t i;
- r = guestfs_int_safe_malloc (g, sizeof (char *) * (Wosize_val (sv) + 1));
- for (i = 0; i < Wosize_val (sv); ++i)
- r[i] = guestfs_int_safe_strdup (g, String_val (Field (sv, i)));
+ r = malloc (sizeof (char *) * (Wosize_val (sv) + 1));
+ if (r == NULL) caml_raise_out_of_memory ();
+ for (i = 0; i < Wosize_val (sv); ++i) {
+ r[i] = strdup (String_val (Field (sv, i)));
+ if (r[i] == NULL) caml_raise_out_of_memory ();
+ }
r[i] = NULL;
CAMLreturnT (char **, r);
@@ -227,7 +230,8 @@ guestfs_int_ocaml_set_event_callback (value gv, value
closure, value events)
event_bitmask = event_bitmask_of_event_list (events);
- value *root = guestfs_int_safe_malloc (g, sizeof *root);
+ value *root = malloc (sizeof *root);
+ if (root == NULL) caml_raise_out_of_memory ();
*root = closure;
eh = guestfs_set_event_callback (g, event_callback_wrapper,
@@ -307,7 +311,8 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
}
/* Copy them into the return array. */
- r = guestfs_int_safe_malloc (g, sizeof (value *) * (*len_rtn));
+ r = malloc (sizeof (value *) * (*len_rtn));
+ if (r == NULL) caml_raise_out_of_memory ();
i = 0;
root = guestfs_first_private (g, &key);
--
2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 3/7] python: Stop using the safe_malloc, etc. functions.
---
python/guestfs-py-byhand.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/python/guestfs-py-byhand.c b/python/guestfs-py-byhand.c
index 6d3e71d..b200dc6 100644
--- a/python/guestfs-py-byhand.c
+++ b/python/guestfs-py-byhand.c
@@ -75,6 +75,8 @@ guestfs_int_py_close (PyObject *self, PyObject *args)
* in a double-free here. XXX
*/
callbacks = get_all_event_callbacks (g, &len);
+ if (callbacks == NULL)
+ return NULL;
if (PyEval_ThreadsInitialized ())
py_save = PyEval_SaveThread ();
@@ -251,7 +253,11 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
}
/* Copy them into the return array. */
- r = guestfs_int_safe_malloc (g, sizeof (PyObject *) * (*len_rtn));
+ r = malloc (sizeof (PyObject *) * (*len_rtn));
+ if (r == NULL) {
+ PyErr_SetNone (PyExc_MemoryError);
+ return NULL;
+ }
i = 0;
cb = guestfs_first_private (g, &key);
--
2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 4/7] java: Stop using the safe_malloc, etc. functions.
---
generator/java.ml | 80 ++++++++++++++++------
generator/main.ml | 1 +
java/Makefile.am | 3 +-
.../et/libguestfs/LibGuestFSOutOfMemory.java | 37 ++++++++++
java/examples/guestfs-java.pod | 3 +
5 files changed, 102 insertions(+), 22 deletions(-)
create mode 100644 java/com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java
diff --git a/generator/java.ml b/generator/java.ml
index 08e3a5f..7bcd329 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -576,7 +576,7 @@ struct callback_data {
jmethodID method; // callback.event method
};
-static struct callback_data **get_all_event_callbacks (guestfs_h *g, size_t
*len_rtn);
+static struct callback_data **get_all_event_callbacks (JNIEnv *env, guestfs_h
*g, size_t *len_rtn);
/* Note that this function returns. The exception is not thrown
* until after the wrapper function returns.
@@ -590,6 +590,18 @@ throw_exception (JNIEnv *env, const char *msg)
(*env)->ThrowNew (env, cl, msg);
}
+/* Note that this function returns. The exception is not thrown
+ * until after the wrapper function returns.
+ */
+static void
+throw_out_of_memory (JNIEnv *env, const char *msg)
+{
+ jclass cl;
+ cl = (*env)->FindClass (env,
+
\"com/redhat/et/libguestfs/LibGuestFSOutOfMemory\");
+ (*env)->ThrowNew (env, cl, msg);
+}
+
JNIEXPORT jlong JNICALL
Java_com_redhat_et_libguestfs_GuestFS__1create (JNIEnv *env,
jobject obj_unused, jint flags)
@@ -617,7 +629,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
* user deletes events in one of the callbacks that we are
* about to invoke, resulting in a double-free. XXX
*/
- data = get_all_event_callbacks (g, &len);
+ data = get_all_event_callbacks (env, g, &len);
guestfs_close (g);
@@ -717,7 +729,11 @@
Java_com_redhat_et_libguestfs_GuestFS__1set_1event_1callback
return -1;
}
- data = guestfs_int_safe_malloc (g, sizeof *data);
+ data = malloc (sizeof *data);
+ if (data == NULL) {
+ throw_out_of_memory (env, \"malloc\");
+ return -1;
+ }
(*env)->GetJavaVM (env, &data->jvm);
data->method = method;
@@ -779,7 +795,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1event_1to_1string
}
static struct callback_data **
-get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
+get_all_event_callbacks (JNIEnv *env, guestfs_h *g, size_t *len_rtn)
{
struct callback_data **r;
size_t i;
@@ -796,7 +812,11 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
}
/* Copy them into the return array. */
- r = guestfs_int_safe_malloc (g, sizeof (struct callback_data *) *
(*len_rtn));
+ r = malloc (sizeof (struct callback_data *) * (*len_rtn));
+ if (r == NULL) {
+ throw_out_of_memory (env, \"malloc\");
+ return NULL;
+ }
i = 0;
data = guestfs_first_private (g, &key);
@@ -961,6 +981,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr "\n";
(* Get the parameters. *)
+ let add_ret_error_label = ref false in
List.iter (
function
| Pathname n
@@ -981,7 +1002,12 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr " %s_size = (*env)->GetArrayLength (env, j%s);\n"
n n
| StringList n | DeviceList n | FilenameList n ->
pr " %s_len = (*env)->GetArrayLength (env, j%s);\n" n
n;
- pr " %s = guestfs_int_safe_malloc (g, sizeof (char *) *
(%s_len+1));\n" n n;
+ pr " %s = malloc (sizeof (char *) * (%s_len+1));\n" n n;
+ pr " if (%s == NULL) {\n" n;
+ pr " throw_out_of_memory (env,
\"malloc\");\n";
+ pr " goto ret_error;\n";
+ add_ret_error_label := true;
+ pr " }\n";
pr " for (i = 0; i < %s_len; ++i) {\n" n;
pr " jobject o = (*env)->GetObjectArrayElement (env,
j%s, i);\n"
n;
@@ -1007,7 +1033,12 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
n n
| OStringList n ->
pr " %s_len = (*env)->GetArrayLength (env, j%s);\n" n
n;
- pr " %s = guestfs_int_safe_malloc (g, sizeof (char *) *
(%s_len+1));\n" n n;
+ pr " %s = malloc (sizeof (char *) * (%s_len+1));\n" n n;
+ pr " if (%s == NULL) {\n" n;
+ pr " throw_out_of_memory (env,
\"malloc\");\n";
+ pr " goto ret_error;\n";
+ add_ret_error_label := true;
+ pr " }\n";
pr " for (i = 0; i < %s_len; ++i) {\n" n;
pr " jobject o = (*env)->GetObjectArrayElement (env,
j%s, i);\n"
n;
@@ -1084,25 +1115,14 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr " if (r == NULL) {\n";
);
pr " throw_exception (env, guestfs_last_error (g));\n";
- (match ret with
- | RErr ->
- pr " return;\n"
- | RInt _
- | RInt64 _
- | RBool _ ->
- pr " return -1;\n"
- | RConstString _ | RConstOptString _ | RString _
- | RBufferOut _
- | RStruct _ | RHashtable _
- | RStringList _ | RStructList _ ->
- pr " return NULL;\n"
- );
+ pr " goto ret_error;\n";
+ add_ret_error_label := true;
pr " }\n"
);
(* Return value. *)
(match ret with
- | RErr -> ()
+ | RErr -> pr " return;\n";
| RInt _ -> pr " return (jint) r;\n"
| RBool _ -> pr " return (jboolean) r;\n"
| RInt64 _ -> pr " return (jlong) r;\n"
@@ -1140,6 +1160,24 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr " return jr;\n"
);
+ if !add_ret_error_label then (
+ pr "\n";
+ pr " ret_error:\n";
+ (match ret with
+ | RErr ->
+ pr " return;\n"
+ | RInt _
+ | RInt64 _
+ | RBool _ ->
+ pr " return -1;\n"
+ | RConstString _ | RConstOptString _ | RString _
+ | RBufferOut _
+ | RStruct _ | RHashtable _
+ | RStringList _ | RStructList _ ->
+ pr " return NULL;\n"
+ );
+ );
+
pr "}\n";
pr "\n"
) external_functions_sorted
diff --git a/generator/main.ml b/generator/main.ml
index 0230a2f..b209511 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -145,6 +145,7 @@ Run it from the top source directory using the command
) external_structs;
delete_except_generated
~skip:["java/com/redhat/et/libguestfs/LibGuestFSException.java";
+
"java/com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java";
"java/com/redhat/et/libguestfs/EventCallback.java"]
"java/com/redhat/et/libguestfs/*.java";
diff --git a/java/Makefile.am b/java/Makefile.am
index 8cfda74..0651fd3 100644
--- a/java/Makefile.am
+++ b/java/Makefile.am
@@ -31,7 +31,8 @@ include $(srcdir)/Makefile.inc
java_sources = \
$(java_built_sources) \
com/redhat/et/libguestfs/EventCallback.java \
- com/redhat/et/libguestfs/LibGuestFSException.java
+ com/redhat/et/libguestfs/LibGuestFSException.java \
+ com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java
java_tests = \
Bindtests.java \
diff --git a/java/com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java
b/java/com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java
new file mode 100644
index 0000000..bc4c929
--- /dev/null
+++ b/java/com/redhat/et/libguestfs/LibGuestFSOutOfMemory.java
@@ -0,0 +1,37 @@
+/* libguestfs Java bindings
+ * Copyright (C) 2009-2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package com.redhat.et.libguestfs;
+
+/**
+ * Libguestfs out of memory class.
+ * <p>
+ * This exception is thrown when malloc or a similar call fails
+ * in the bindings.
+ *
+ * @author rjones
+ * @see Error
+ */
+public class LibGuestFSOutOfMemory extends Error {
+ private static final long serialVersionUID = 1L;
+
+ public LibGuestFSOutOfMemory (String msg)
+ {
+ super (msg);
+ }
+}
diff --git a/java/examples/guestfs-java.pod b/java/examples/guestfs-java.pod
index 53276e8..bcff388 100644
--- a/java/examples/guestfs-java.pod
+++ b/java/examples/guestfs-java.pod
@@ -38,6 +38,9 @@ is the error message (a C<String>).
Calling any method on a closed handle raises the same exception.
+If L<malloc(3)> or some other allocation fails inside the bindings,
+the C<LibGuestFSOutOfMemory> exception is thrown.
+
=head2 EVENTS
The L<libguestfs event API|guestfs(3)/EVENTS> is fully supported from
--
2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 5/7] perl: Stop using the safe_malloc, etc. functions.
---
generator/perl.ml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/generator/perl.ml b/generator/perl.ml
index cec7fb7..6876b0f 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -176,7 +176,8 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
}
/* Copy them into the return array. */
- r = guestfs_int_safe_malloc (g, sizeof (SV *) * (*len_rtn));
+ r = malloc (sizeof (SV *) * (*len_rtn));
+ if (r == NULL) croak (\"malloc: %%m\");
i = 0;
cb = guestfs_first_private (g, &key);
@@ -477,7 +478,8 @@ PREINIT:
pr " /* Note av_len returns index of final
element. */\n";
pr " len = av_len (av) + 1;\n";
pr "\n";
- pr " r = guestfs_int_safe_malloc (g, (len+1) *
sizeof (char *));\n";
+ pr " r = malloc ((len+1) * sizeof (char
*));\n";
+ pr " if (r == NULL) croak (\"malloc:
%%m\");\n";
pr " for (i = 0; i < len; ++i) {\n";
pr " svp = av_fetch (av, i, 0);\n";
pr " r[i] = SvPV_nolen (*svp);\n";
--
2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 6/7] ruby: Stop using the safe_malloc, etc. functions.
--- generator/ruby.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generator/ruby.ml b/generator/ruby.ml index 1b05bf7..db222ea 100644 --- a/generator/ruby.ml +++ b/generator/ruby.ml @@ -260,7 +260,9 @@ set_event_callback (VALUE gv, VALUE cbv, VALUE event_bitmaskv) event_bitmask = NUM2ULL (event_bitmaskv); - root = guestfs_int_safe_malloc (g, sizeof *root); + root = malloc (sizeof *root); + if (root == NULL) + rb_raise (rb_eNoMemError, \"malloc: %%m\"); *root = cbv; eh = guestfs_set_event_callback (g, event_callback_wrapper, @@ -431,7 +433,9 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn) } /* Copy them into the return array. */ - r = guestfs_int_safe_malloc (g, sizeof (VALUE *) * (*len_rtn)); + r = malloc (sizeof (VALUE *) * (*len_rtn)); + if (r == NULL) + rb_raise (rb_eNoMemError, \"malloc: %%m\"); i = 0; root = guestfs_first_private (g, &key); -- 2.5.0
Richard W.M. Jones
2016-Feb-05 14:21 UTC
[Libguestfs] [PATCH 7/7] lib: Stop exporting the safe_malloc, etc. functions.
As was forewarned in the comment, stop exporting these functions
outside the library.
---
generator/c.ml | 8 --------
src/guestfs-internal-frontend.h | 23 -----------------------
src/guestfs-internal.h | 20 ++++++++++++++++++++
3 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/generator/c.ml b/generator/c.ml
index e6287ed..c432356 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -2187,14 +2187,6 @@ and generate_linker_script ()
"guestfs_set_private";
"guestfs_set_progress_callback";
"guestfs_set_subprocess_quit_callback";
-
- (* Unofficial parts of the API: the bindings code use these
- * functions, so it is useful to export them.
- *)
- "guestfs_int_safe_calloc";
- "guestfs_int_safe_malloc";
- "guestfs_int_safe_strdup";
- "guestfs_int_safe_memdup";
] in
let functions List.flatten (
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 2aaca9a..7f10906 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -72,29 +72,6 @@
#define CLEANUP_PCLOSE
#endif
-/* NB: At some point we will stop exporting these safe_* allocation
- * functions outside the library, so don't use them in new tools or
- * bindings code.
- */
-extern GUESTFS_DLL_PUBLIC void *guestfs_int_safe_malloc (guestfs_h *g, size_t
nbytes);
-extern GUESTFS_DLL_PUBLIC void *guestfs_int_safe_calloc (guestfs_h *g, size_t
n, size_t s);
-extern GUESTFS_DLL_PUBLIC char *guestfs_int_safe_strdup (guestfs_h *g, const
char *str);
-extern GUESTFS_DLL_PUBLIC void *guestfs_int_safe_memdup (guestfs_h *g, const
void *ptr, size_t size);
-extern void *guestfs_int_safe_realloc (guestfs_h *g, void *ptr, size_t nbytes);
-extern char *guestfs_int_safe_strdup (guestfs_h *g, const char *str);
-extern char *guestfs_int_safe_strndup (guestfs_h *g, const char *str, size_t
n);
-extern void *guestfs_int_safe_memdup (guestfs_h *g, const void *ptr, size_t
size);
-extern char *guestfs_int_safe_asprintf (guestfs_h *g, const char *fs, ...)
- __attribute__((format (printf,2,3)));
-
-#define safe_calloc guestfs_int_safe_calloc
-#define safe_malloc guestfs_int_safe_malloc
-#define safe_realloc guestfs_int_safe_realloc
-#define safe_strdup guestfs_int_safe_strdup
-#define safe_strndup guestfs_int_safe_strndup
-#define safe_memdup guestfs_int_safe_memdup
-#define safe_asprintf guestfs_int_safe_asprintf
-
/* utils.c */
extern void guestfs_int_free_string_list (char **);
extern size_t guestfs_int_count_strings (char *const *);
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 6e441e4..22b6c6c 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -626,6 +626,26 @@ struct guestfs_progress;
/* handle.c */
extern int guestfs_int_get_backend_setting_bool (guestfs_h *g, const char
*name);
+/* alloc.c */
+extern void *guestfs_int_safe_malloc (guestfs_h *g, size_t nbytes);
+extern void *guestfs_int_safe_calloc (guestfs_h *g, size_t n, size_t s);
+extern char *guestfs_int_safe_strdup (guestfs_h *g, const char *str);
+extern void *guestfs_int_safe_memdup (guestfs_h *g, const void *ptr, size_t
size);
+extern void *guestfs_int_safe_realloc (guestfs_h *g, void *ptr, size_t nbytes);
+extern char *guestfs_int_safe_strdup (guestfs_h *g, const char *str);
+extern char *guestfs_int_safe_strndup (guestfs_h *g, const char *str, size_t
n);
+extern void *guestfs_int_safe_memdup (guestfs_h *g, const void *ptr, size_t
size);
+extern char *guestfs_int_safe_asprintf (guestfs_h *g, const char *fs, ...)
+ __attribute__((format (printf,2,3)));
+
+#define safe_calloc guestfs_int_safe_calloc
+#define safe_malloc guestfs_int_safe_malloc
+#define safe_realloc guestfs_int_safe_realloc
+#define safe_strdup guestfs_int_safe_strdup
+#define safe_strndup guestfs_int_safe_strndup
+#define safe_memdup guestfs_int_safe_memdup
+#define safe_asprintf guestfs_int_safe_asprintf
+
/* errors.c */
extern void guestfs_int_init_error_handler (guestfs_h *g);
--
2.5.0