Browse Source

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>
ppa-0.6.1
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
337075dc8c
  1. 4
      ccan_compat.h
  2. 3
      cli/lightning-cli.c
  3. 4
      common/json_escaped.c
  4. 3
      common/memleak.c
  5. 4
      common/utils.c
  6. 3
      devtools/bolt11-cli.c
  7. 2
      lightningd/options.c
  8. 3
      lightningd/param.c
  9. 2
      wallet/db.c

4
ccan_compat.h

@ -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 */

3
cli/lightning-cli.c

@ -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)

4
common/json_escaped.c

@ -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;

3
common/memleak.c

@ -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;

4
common/utils.c

@ -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");
}
}

3
devtools/bolt11-cli.c

@ -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)

2
lightningd/options.c

@ -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)

3
lightningd/param.c

@ -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)) {

2
wallet/db.c

@ -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;
}

Loading…
Cancel
Save