#include <sys/types.h>
#include <dirent.h>
#include <arpa/inet.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
#if defined(HAVE_BSD_NSS)
# include <nsswitch.h>
#endif
-#include "viralloc.h"
-#include "virtime.h"
#include "configmake.h"
#include "libvirt_nss_leases.h"
DEBUG("Processing %s", path);
if (findMACs(path, name, &macs, &nmacs) < 0) {
- VIR_FREE(path);
+ free(path);
goto cleanup;
}
- VIR_FREE(path);
+ free(path);
#endif /* LIBVIRT_NSS_GUEST */
}
{
enum nss_status ret = NSS_STATUS_UNAVAIL;
char *r_name, **r_aliases, *r_addr, *r_addr_next, **r_addr_list;
- VIR_AUTOFREE(leaseAddress *) addr = NULL;
+ leaseAddress *addr = NULL;
size_t naddr, i;
bool found = false;
size_t nameLen, need, idx = 0;
af = AF_INET;
if ((r = findLease(name, af, &addr, &naddr, &found, errnop)) < 0) {
+ free(addr);
/* Error occurred. Return immediately. */
if (*errnop == EAGAIN) {
*herrnop = TRY_AGAIN;
/* NOT found */
*errnop = ESRCH;
*herrnop = HOST_NOT_FOUND;
+ free(addr);
return NSS_STATUS_NOTFOUND;
} else if (!naddr) {
/* Found, but no data */
*errnop = ENXIO;
*herrnop = NO_DATA;
+ free(addr);
return NSS_STATUS_UNAVAIL;
}
ret = NSS_STATUS_SUCCESS;
cleanup:
+ free(addr);
return ret;
}
#if 0
-# include "virerror.h"
+# include <errno.h>
# define ERROR(...) \
do { \
char ebuf[1024]; \
+ strerror_r(errno, ebuf, sizeof(ebuf)); \
fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, " : %s\n", virStrerror(errno, ebuf, sizeof(ebuf))); \
+ fprintf(stderr, " : %s\n", ebuf); \
fprintf(stderr, "\n"); \
} while (0)
#include "libvirt_nss_leases.h"
#include "libvirt_nss.h"
-#include "viralloc.h"
enum {
FIND_LEASES_STATE_START,
} sa;
unsigned char addr[16];
int err;
+ leaseAddress *newAddr;
DEBUG("IP address: %s", ipAddr);
}
}
- if (VIR_REALLOC_N_QUIET(*tmpAddress, *ntmpAddress + 1) < 0) {
+ newAddr = realloc(*tmpAddress, sizeof(*newAddr) * (*ntmpAddress + 1));
+ if (!newAddr) {
ERROR("Out of memory");
return -1;
}
+ *tmpAddress = newAddr;
(*tmpAddress)[*ntmpAddress].expirytime = expirytime;
(*tmpAddress)[*ntmpAddress].af = family;