+/*
+ * vstrallocf - copies printf formatted string into newly allocated memory.
+ */
+char *
+debug_vstrallocf(
+ const char *fmt,
+ ...)
+{
+ char * result;
+ size_t size;
+ va_list argp;
+
+ debug_alloc_pop();
+ malloc_enter(debug_caller_loc(saved_file, saved_line));
+
+ result = debug_alloc(saved_file, saved_line, MIN_ALLOC);
+ if (result != NULL) {
+
+ arglist_start(argp, fmt);
+ size = vsnprintf(result, MIN_ALLOC, fmt, argp);
+ arglist_end(argp);
+
+ if (size >= (size_t)MIN_ALLOC) {
+ amfree(result);
+ result = debug_alloc(saved_file, saved_line, size + 1);
+
+ arglist_start(argp, fmt);
+ (void)vsnprintf(result, size + 1, fmt, argp);
+ arglist_end(argp);
+ }
+ }
+
+ malloc_leave(debug_caller_loc(saved_file, saved_line));
+ return result;
+}
+
+extern char **environ;