Browse Source

Add xtalloc_asprintf

I expect this to be useful in the upcoming implementation of token pasting.
tags/mesa-7.9-rc1
Carl Worth 15 years ago
parent
commit
b894583fd0
2 changed files with 21 additions and 0 deletions
  1. 3
    0
      glcpp.h
  2. 18
    0
      xtalloc.c

+ 3
- 0
glcpp.h View File

@@ -149,4 +149,7 @@ xtalloc_strdup (const void *t, const char *p);
char *
xtalloc_strndup (const void *t, const char *p, size_t n);

char *
xtalloc_asprintf (const void *t, const char *fmt, ...);

#endif

+ 18
- 0
xtalloc.c View File

@@ -64,3 +64,21 @@ xtalloc_strndup (const void *t, const char *p, size_t n)

return ret;
}

char *
xtalloc_asprintf (const void *t, const char *fmt, ...)
{
va_list ap;
char *ret;

va_start(ap, fmt);

ret = talloc_vasprintf(t, fmt, ap);
if (ret == NULL) {
fprintf (stderr, "Out of memory.\n");
exit (1);
}

va_end(ap);
return ret;
}

Loading…
Cancel
Save