tal: don't access low-level tal functions.

In several places we use low-level tal functions because we want the
label to be something other than the default.  ccan/tal is adding
tal_*_label so replace them and shim it for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-07-28 15:30:20 +09:30 committed by Christian Decker
parent 5cf34d6618
commit 337075dc8c
9 changed files with 14 additions and 14 deletions

View File

@ -19,5 +19,9 @@
/* Transition for ccan update. */
#define tal_bytelen(x) tal_len(x)
#define tal_arr_label(ctx, type, len, label) \
((type *)tal_alloc_arr_(ctx, sizeof(type), len, false, true, label))
#define tal_arrz_label(ctx, type, len, label) \
((type *)tal_alloc_arr_(ctx, sizeof(type), len, true, true, label))
#endif /* LIGHTNING_CCAN_COMPAT_H */

View File

@ -24,8 +24,7 @@
/* Tal wrappers for opt. */
static void *opt_allocfn(size_t size)
{
return tal_alloc_(NULL, size, false, false,
TAL_LABEL("opt_allocfn", ""));
return tal_arr_label(NULL, char, size, TAL_LABEL("opt_allocfn", ""));
}
static void *tal_reallocfn(void *ptr, size_t size)

View File

@ -6,8 +6,8 @@ struct json_escaped *json_escaped_string_(const tal_t *ctx,
{
struct json_escaped *esc;
esc = tal_alloc_arr_(ctx, 1, len + 1, false, true,
TAL_LABEL(struct json_escaped, ""));
esc = (void *)tal_arr_label(ctx, char, len + 1,
TAL_LABEL(struct json_escaped, ""));
memcpy(esc->s, bytes, len);
esc->s[len] = '\0';
return esc;

View File

@ -224,8 +224,7 @@ static int append_bt(void *data, uintptr_t pc)
static void add_backtrace(tal_t *parent UNUSED, enum tal_notify_type type UNNEEDED,
void *child)
{
uintptr_t *bt = tal_alloc_arr_(child, sizeof(uintptr_t), 32, true, true,
"backtrace");
uintptr_t *bt = tal_arrz_label(child, uintptr_t, 32, "backtrace");
/* First serves as counter. */
bt[0] = 1;

View File

@ -39,7 +39,7 @@ void setup_locale(void)
/* Initial creation of tmpctx. */
void setup_tmpctx(void)
{
tmpctx = tal_alloc_(NULL, 0, false, false, "tmpctx");
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
}
/* Free any children of tmpctx. */
@ -48,6 +48,6 @@ void clean_tmpctx(void)
/* Minor optimization: don't do anything if tmpctx unused. */
if (tal_first(tmpctx)) {
tal_free(tmpctx);
tmpctx = tal_alloc_(NULL, 0, false, false, "tmpctx");
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
}
}

View File

@ -26,8 +26,7 @@
/* Tal wrappers for opt. */
static void *opt_allocfn(size_t size)
{
return tal_alloc_(NULL, size, false, false,
TAL_LABEL("opt_allocfn", ""));
return tal_arr_label(NULL, char, size, TAL_LABEL("opt_allocfn", ""));
}
static void *tal_reallocfn(void *ptr, size_t size)

View File

@ -39,7 +39,7 @@ bool deprecated_apis = true;
/* Tal wrappers for opt. */
static void *opt_allocfn(size_t size)
{
return tal_alloc_(NULL, size, false, false, TAL_LABEL("opt_allocfn", ""));
return tal_arr_label(NULL, char, size, TAL_LABEL("opt_allocfn", ""));
}
static void *tal_reallocfn(void *ptr, size_t size)

View File

@ -80,8 +80,7 @@ static bool make_callback(struct command *cmd,
if (def->argsize && def->cb != (param_cb)json_tok_tok) {
*(void **)def->arg
= arg
= tal_alloc_(cmd, def->argsize, false, false,
"param");
= tal_arr_label(cmd, char, def->argsize, "param");
} else
arg = def->arg;
if (!def->cb(buffer, tok, arg)) {

View File

@ -701,7 +701,7 @@ void *sqlite3_column_arr_(const tal_t *ctx, sqlite3_stmt *stmt, int col,
fatal("%s: column size %zu not a multiple of %s (%zu)",
caller, sourcelen, label, bytes);
p = tal_alloc_arr_(ctx, bytes, sourcelen / bytes, false, true, label);
p = tal_arr_label(ctx, char, sourcelen, label);
memcpy(p, sqlite3_column_blob(stmt, col), sourcelen);
return p;
}