version 1.8, 2004/09/28 15:10:50 |
version 1.9, 2007/07/26 16:10:15 |
|
|
/* |
/* |
* Copyright (c) 1999-2003 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1999-2005 Todd C. Miller <Todd.Miller@courtesan.com> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
* Materiel Command, USAF, under agreement number F39502-99-1-0512. |
* Materiel Command, USAF, under agreement number F39502-99-1-0512. |
*/ |
*/ |
|
|
#include "config.h" |
#include <config.h> |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> |
#include <sys/param.h> |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: alloc.c,v 1.23 2004/06/01 16:23:32 millert Exp $"; |
__unused static const char rcsid[] = "$Sudo: alloc.c,v 1.23.2.3 2007/06/12 01:43:01 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
#ifdef __STDC__ |
#ifdef __STDC__ |
easprintf(char **ret, const char *fmt, ...) |
easprintf(char **ret, const char *fmt, ...) |
#else |
#else |
easprintf(va_alist) |
easprintf(ret, fmt, va_alist) |
|
char **ret; |
|
const char *fmt; |
va_dcl |
va_dcl |
#endif |
#endif |
{ |
{ |
|
|
#ifdef __STDC__ |
#ifdef __STDC__ |
va_start(ap, fmt); |
va_start(ap, fmt); |
#else |
#else |
char **ret; |
|
const char *fmt; |
|
|
|
va_start(ap); |
va_start(ap); |
ret = va_arg(ap, char **); |
|
fmt = va_arg(ap, const char *); |
|
#endif |
#endif |
len = vasprintf(ret, fmt, ap); |
len = vasprintf(ret, fmt, ap); |
va_end(ap); |
va_end(ap); |
|
|
if ((len = vasprintf(ret, format, args)) == -1) |
if ((len = vasprintf(ret, format, args)) == -1) |
errx(1, "unable to allocate memory"); |
errx(1, "unable to allocate memory"); |
return(len); |
return(len); |
|
} |
|
|
|
/* |
|
* Wrapper for free(3) so we can depend on C89 semantics. |
|
*/ |
|
void |
|
efree(ptr) |
|
VOID *ptr; |
|
{ |
|
if (ptr != NULL) |
|
free(ptr); |
} |
} |