common: Add tal_arr_remove helper

Suggested-by: Rusty Russell <@rustyrussell>
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2018-12-03 14:38:19 +01:00
committed by Rusty Russell
parent 906bfef4fd
commit 9ce3e960ec
2 changed files with 21 additions and 0 deletions

View File

@@ -29,6 +29,15 @@ u8 *tal_hexdata(const tal_t *ctx, const void *str, size_t len);
(tal_resize((p), tal_count(*(p))+1), (*p) + tal_count(*(p))-1)
#endif
/**
* Remove an element from an array
*
* This will shift the elements past the removed element, changing
* their position in memory, so only use this for arrays of pointers.
*/
#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);
/* Use the POSIX C locale. */
void setup_locale(void);