mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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:
committed by
Christian Decker
parent
5cf34d6618
commit
337075dc8c
@@ -19,5 +19,9 @@
|
|||||||
|
|
||||||
/* Transition for ccan update. */
|
/* Transition for ccan update. */
|
||||||
#define tal_bytelen(x) tal_len(x)
|
#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 */
|
#endif /* LIGHTNING_CCAN_COMPAT_H */
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
/* Tal wrappers for opt. */
|
/* Tal wrappers for opt. */
|
||||||
static void *opt_allocfn(size_t size)
|
static void *opt_allocfn(size_t size)
|
||||||
{
|
{
|
||||||
return tal_alloc_(NULL, size, false, false,
|
return tal_arr_label(NULL, char, size, TAL_LABEL("opt_allocfn", ""));
|
||||||
TAL_LABEL("opt_allocfn", ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *tal_reallocfn(void *ptr, size_t size)
|
static void *tal_reallocfn(void *ptr, size_t size)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ struct json_escaped *json_escaped_string_(const tal_t *ctx,
|
|||||||
{
|
{
|
||||||
struct json_escaped *esc;
|
struct json_escaped *esc;
|
||||||
|
|
||||||
esc = tal_alloc_arr_(ctx, 1, len + 1, false, true,
|
esc = (void *)tal_arr_label(ctx, char, len + 1,
|
||||||
TAL_LABEL(struct json_escaped, ""));
|
TAL_LABEL(struct json_escaped, ""));
|
||||||
memcpy(esc->s, bytes, len);
|
memcpy(esc->s, bytes, len);
|
||||||
esc->s[len] = '\0';
|
esc->s[len] = '\0';
|
||||||
return esc;
|
return esc;
|
||||||
|
|||||||
@@ -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,
|
static void add_backtrace(tal_t *parent UNUSED, enum tal_notify_type type UNNEEDED,
|
||||||
void *child)
|
void *child)
|
||||||
{
|
{
|
||||||
uintptr_t *bt = tal_alloc_arr_(child, sizeof(uintptr_t), 32, true, true,
|
uintptr_t *bt = tal_arrz_label(child, uintptr_t, 32, "backtrace");
|
||||||
"backtrace");
|
|
||||||
|
|
||||||
/* First serves as counter. */
|
/* First serves as counter. */
|
||||||
bt[0] = 1;
|
bt[0] = 1;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void setup_locale(void)
|
|||||||
/* Initial creation of tmpctx. */
|
/* Initial creation of tmpctx. */
|
||||||
void setup_tmpctx(void)
|
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. */
|
/* Free any children of tmpctx. */
|
||||||
@@ -48,6 +48,6 @@ void clean_tmpctx(void)
|
|||||||
/* Minor optimization: don't do anything if tmpctx unused. */
|
/* Minor optimization: don't do anything if tmpctx unused. */
|
||||||
if (tal_first(tmpctx)) {
|
if (tal_first(tmpctx)) {
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
tmpctx = tal_alloc_(NULL, 0, false, false, "tmpctx");
|
tmpctx = tal_arr_label(NULL, char, 0, "tmpctx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
/* Tal wrappers for opt. */
|
/* Tal wrappers for opt. */
|
||||||
static void *opt_allocfn(size_t size)
|
static void *opt_allocfn(size_t size)
|
||||||
{
|
{
|
||||||
return tal_alloc_(NULL, size, false, false,
|
return tal_arr_label(NULL, char, size, TAL_LABEL("opt_allocfn", ""));
|
||||||
TAL_LABEL("opt_allocfn", ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *tal_reallocfn(void *ptr, size_t size)
|
static void *tal_reallocfn(void *ptr, size_t size)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ bool deprecated_apis = true;
|
|||||||
/* Tal wrappers for opt. */
|
/* Tal wrappers for opt. */
|
||||||
static void *opt_allocfn(size_t size)
|
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)
|
static void *tal_reallocfn(void *ptr, size_t size)
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ static bool make_callback(struct command *cmd,
|
|||||||
if (def->argsize && def->cb != (param_cb)json_tok_tok) {
|
if (def->argsize && def->cb != (param_cb)json_tok_tok) {
|
||||||
*(void **)def->arg
|
*(void **)def->arg
|
||||||
= arg
|
= arg
|
||||||
= tal_alloc_(cmd, def->argsize, false, false,
|
= tal_arr_label(cmd, char, def->argsize, "param");
|
||||||
"param");
|
|
||||||
} else
|
} else
|
||||||
arg = def->arg;
|
arg = def->arg;
|
||||||
if (!def->cb(buffer, tok, arg)) {
|
if (!def->cb(buffer, tok, arg)) {
|
||||||
|
|||||||
@@ -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)",
|
fatal("%s: column size %zu not a multiple of %s (%zu)",
|
||||||
caller, sourcelen, label, bytes);
|
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);
|
memcpy(p, sqlite3_column_blob(stmt, col), sourcelen);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user