mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 17:10:11 +01:00
Add xtalloc_reference.
Yet another talloc wrapper that should come in handy.
This commit is contained in:
parent
3ff8167084
commit
9bb796f33a
2 changed files with 21 additions and 0 deletions
6
glcpp.h
6
glcpp.h
|
|
@ -164,4 +164,10 @@ xtalloc_strndup (const void *t, const char *p, size_t n);
|
|||
char *
|
||||
xtalloc_asprintf (const void *t, const char *fmt, ...);
|
||||
|
||||
void *
|
||||
_xtalloc_reference_loc (const void *context,
|
||||
const void *ptr, const char *location);
|
||||
|
||||
#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
15
xtalloc.c
15
xtalloc.c
|
|
@ -82,3 +82,18 @@ xtalloc_asprintf (const void *t, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *
|
||||
_xtalloc_reference_loc (const void *context,
|
||||
const void *ptr, const char *location)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
ret = _talloc_reference_loc (context, ptr, location);
|
||||
if (ret == NULL) {
|
||||
fprintf (stderr, "Out of memory.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue