nostrdb: ccan: sync with normal versions.

This is the version of CCAN which CLN was using at the time these
were taken.  Unfortunately lots of whitespace has been changed,
but AFAICT no source changes.

Here's the command I ran (with ../ccan checked out to 1ae4c432):

```
make update-ccan CCAN_NEW="alignof array_size build_assert check_type container_of cppmagic likely list mem short_types str structeq take tal tal/str typesafe_cb utf8 endian crypto/sha256"
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Rusty Russell
2024-08-17 15:21:19 +09:30
committed by Daniel D’Aquino
parent 201cdd7edc
commit a8d7d971b1
96 changed files with 36562 additions and 2026 deletions

View File

@@ -1,9 +1,9 @@
/* CC0 (Public domain) - see LICENSE file for details */
#ifndef CCAN_TAKE_H
#define CCAN_TAKE_H
#include "../config.h"
#include "config.h"
#include <stdbool.h>
#include "str.h"
#include <ccan/str/str.h>
#ifdef CCAN_TAKE_DEBUG
#define TAKE_LABEL(p) __FILE__ ":" stringify(__LINE__) ":" stringify(p)
@@ -17,8 +17,8 @@
* This doesn't do anything, but useful for documentation.
*
* Example:
* void print_string(const char *str TAKES);
*
* void print_string(const char *str TAKES);
*
*/
#define TAKES
@@ -41,18 +41,18 @@
* this only returns true once.
*
* Example:
* // Silly routine to add 1
* static int *add_one(const int *num TAKES)
* {
* int *ret;
* if (taken(num))
* ret = (int *)num;
* else
* ret = malloc(sizeof(int));
* if (ret)
* *ret = (*num) + 1;
* return ret;
* }
* // Silly routine to add 1
* static int *add_one(const int *num TAKES)
* {
* int *ret;
* if (taken(num))
* ret = (int *)num;
* else
* ret = malloc(sizeof(int));
* if (ret)
* *ret = (*num) + 1;
* return ret;
* }
*/
bool taken(const void *p);
@@ -63,15 +63,15 @@ bool taken(const void *p);
* This is like the above, but doesn't remove it from the taken list.
*
* Example:
* // Silly routine to add 1: doesn't handle taken args!
* static int *add_one_notake(const int *num)
* {
* int *ret = malloc(sizeof(int));
* assert(!is_taken(num));
* if (ret)
* *ret = (*num) + 1;
* return ret;
* }
* // Silly routine to add 1: doesn't handle taken args!
* static int *add_one_notake(const int *num)
* {
* int *ret = malloc(sizeof(int));
* assert(!is_taken(num));
* if (ret)
* *ret = (*num) + 1;
* return ret;
* }
*/
bool is_taken(const void *p);
@@ -83,10 +83,10 @@ bool is_taken(const void *p);
* a static char buffer with the pointer value in it. NULL if none are taken.
*
* Example:
* static void cleanup(void)
* {
* assert(!taken_any());
* }
* static void cleanup(void)
* {
* assert(!taken_any());
* }
*/
const char *taken_any(void);
@@ -96,10 +96,10 @@ const char *taken_any(void);
* This is useful in atexit() handlers for valgrind-style leak detection.
*
* Example:
* static void cleanup2(void)
* {
* take_cleanup();
* }
* static void cleanup2(void)
* {
* take_cleanup();
* }
*/
void take_cleanup(void);
@@ -113,15 +113,15 @@ void take_cleanup(void);
* it like any allocation failure.
*
* Example:
* static void free_on_fail(const void *p)
* {
* free((void *)p);
* }
* static void free_on_fail(const void *p)
* {
* free((void *)p);
* }
*
* static void init(void)
* {
* take_allocfail(free_on_fail);
* }
* static void init(void)
* {
* take_allocfail(free_on_fail);
* }
*/
void take_allocfail(void (*fn)(const void *p));