mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
common: tal_dup_talarr() helper.
This is a common thing to do, so create a macro. Unfortunately, it still needs the type arg, because the paramter may be const, and the return cannot be, and C doesn't have a general "(-const)" cast. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -56,6 +56,17 @@ void clear_softref_(const tal_t *outer, size_t outersize, void **ptr);
|
||||
#define tal_arr_remove(p, n) tal_arr_remove_((p), sizeof(**p), (n))
|
||||
void tal_arr_remove_(void *p, size_t elemsize, size_t n);
|
||||
|
||||
/**
|
||||
* The comon case of duplicating an entire tal array.
|
||||
*
|
||||
* A macro because we must not double-evaluate p.
|
||||
*/
|
||||
#define tal_dup_talarr(ctx, type, p) \
|
||||
((type *)tal_dup_talarr_((ctx), tal_typechk_(p, type *), \
|
||||
TAL_LABEL(type, "[]")))
|
||||
void *tal_dup_talarr_(const tal_t *ctx, const tal_t *src TAKES,
|
||||
const char *label);
|
||||
|
||||
/* Use the POSIX C locale. */
|
||||
void setup_locale(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user