extern char *guestfs_safe_strdup (guestfs_h *g, const char *str);
extern char *guestfs_safe_strndup (guestfs_h *g, const char *str, size_t n);
extern void *guestfs_safe_memdup (guestfs_h *g, void *ptr, size_t size);
+extern char *guestfs_safe_asprintf (guestfs_h *g, const char *fs, ...)
+ __attribute__((format (printf,2,3)));
extern void guestfs___print_timestamped_argv (guestfs_h *g, const char *argv[]);
extern void guestfs___print_timestamped_message (guestfs_h *g, const char *fs, ...);
extern void guestfs___free_inspect_info (guestfs_h *g);
#define safe_strdup guestfs_safe_strdup
#define safe_strndup guestfs_safe_strndup
#define safe_memdup guestfs_safe_memdup
+#define safe_asprintf guestfs_safe_asprintf
#ifdef HAVE_PCRE
#define match guestfs___match
#define match1 guestfs___match1
return p;
}
+char *
+guestfs_safe_asprintf (guestfs_h *g, const char *fs, ...)
+{
+ va_list args;
+ char *msg;
+
+ va_start (args, fs);
+ int err = vasprintf (&msg, fs, args);
+ va_end (args);
+
+ if (err == -1)
+ g->abort_cb ();
+
+ return msg;
+}
+
void
guestfs_set_out_of_memory_handler (guestfs_h *g, guestfs_abort_cb cb)
{