return 1;
if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/asprintf\n");
printf("ccan/hash\n");
printf("ccan/likely\n");
printf("ccan/asearch\n");
#include "private.h"
+#include <ccan/asprintf/asprintf.h>
#include <ccan/tdb2/tdb2.h>
#include <assert.h>
#include <stdarg.h>
if (!tdb->logfn)
return ecode;
- /* FIXME: Doesn't assume asprintf. */
va_start(ap, fmt);
- len = vsnprintf(NULL, 0, fmt, ap);
+ len = vasprintf(&message, fmt, ap);
va_end(ap);
- message = malloc(len + 1);
- if (!message) {
+ if (len < 0) {
tdb->logfn(tdb, TDB_LOG_ERROR, tdb->log_private,
"out of memory formatting message:");
tdb->logfn(tdb, level, tdb->log_private, fmt);
- return ecode;
+ } else {
+ tdb->logfn(tdb, level, tdb->log_private, message);
+ free(message);
}
- va_start(ap, fmt);
- len = vsprintf(message, fmt, ap);
- va_end(ap);
- tdb->logfn(tdb, level, tdb->log_private, message);
- free(message);
errno = saved_errno;
return ecode;
}
const struct failtest_call *i, *last = &history[num-1];
if (failmatch(last, INITIAL_TDB_MALLOC)
- || failmatch(last, LOGGING_MALLOC)
|| failmatch(last, URANDOM_OPEN)
|| failmatch(last, URANDOM_READ)) {
if (find_repeat(history, last, last))
#include <stdbool.h>
/* FIXME: Check these! */
-#define INITIAL_TDB_MALLOC "tdb.c", 189, FAILTEST_MALLOC
-#define LOGGING_MALLOC "tdb.c", 766, FAILTEST_MALLOC
+#define INITIAL_TDB_MALLOC "tdb.c", 190, FAILTEST_MALLOC
#define URANDOM_OPEN "tdb.c", 49, FAILTEST_OPEN
#define URANDOM_READ "tdb.c", 29, FAILTEST_READ