common/utils: remove now-unused softref facility.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-06 17:06:50 +09:30
parent 3ce2f28907
commit db7c608e2d
3 changed files with 0 additions and 247 deletions

View File

@@ -57,78 +57,6 @@ void tal_wally_end_onto_(const tal_t *parent,
tal_wally_end(tal_steal(parent, from_wally));
}
#if DEVELOPER
/* If you've got a softref, we assume no reallocs. */
static void dont_move_softref(tal_t *ctx, enum tal_notify_type ntype, void *info)
{
abort();
}
#endif
static void softref_nullify(tal_t *obj, void **ptr)
{
*ptr = NULL;
#if DEVELOPER
tal_del_notifier(obj, dont_move_softref);
#endif
}
static void softref_cleanup(const tal_t *outer, void **ptr)
{
if (*ptr) {
tal_del_destructor2(*ptr, softref_nullify, ptr);
}
#if DEVELOPER
tal_del_notifier(outer, dont_move_softref);
#endif
}
void set_softref_(const tal_t *outer, size_t outersize, void **ptr, tal_t *obj)
{
/* pointer is inside outer, right? */
assert((char *)ptr >= (char *)outer);
assert((char *)ptr < (char *)outer + outersize);
/* This is harmless if there was no prior, otherwise constrains the
* leak: we don't have enough information in softref_nullify to
* clear softref_cleanup */
tal_del_destructor2(outer, softref_cleanup, ptr);
if (obj) {
tal_add_destructor2(outer, softref_cleanup, ptr);
tal_add_destructor2(obj, softref_nullify, ptr);
#if DEVELOPER
tal_add_notifier(obj, TAL_NOTIFY_MOVE, dont_move_softref);
#endif
}
#if DEVELOPER
tal_add_notifier(outer, TAL_NOTIFY_MOVE, dont_move_softref);
#endif
*ptr = obj;
}
void clear_softref_(const tal_t *outer, size_t outersize, void **ptr)
{
assert((char *)ptr >= (char *)outer);
assert((char *)ptr < (char *)outer + outersize);
if (*ptr) {
tal_del_destructor2(outer, softref_cleanup, ptr);
tal_del_destructor2(*ptr, softref_nullify, ptr);
#if DEVELOPER
tal_del_notifier(*ptr, dont_move_softref);
#endif
}
#if DEVELOPER
tal_del_notifier(outer, dont_move_softref);
#endif
*ptr = NULL;
}
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len)
{
char *str = tal_arr(ctx, char, hex_str_size(len));