tal: document tal_steal(ctx, NULL) as OK. master origin/master
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 19 Jun 2020 01:45:21 +0000 (11:15 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 19 Jun 2020 01:45:21 +0000 (11:15 +0930)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/htable/htable_type.h
ccan/tal/tal.h

index de4cd471404f1d4f22a4e184366a0efe9934da7c..bb5ea086b7319fd3cd1c19b0dceece1974cfe8d4 100644 (file)
@@ -35,6 +35,9 @@
  *     bool <name>_del(struct <name> *ht, const <type> *e);
  *     bool <name>_delkey(struct <name> *ht, const <keytype> *k);
  *
+ * Delete by iterator:
+ *     bool <name>_delval(struct <name> *ht, struct <name>_iter *i);
+ *
  * Find and return the (first) matching element, or NULL:
  *     type *<name>_get(const struct @name *ht, const <keytype> *k);
  *
                        return name##_del(ht, elem);                    \
                return false;                                           \
        }                                                               \
-       static inline UNNEEDED bool name##_pick(const struct name *ht,  \
+       static inline UNNEEDED void name##_delval(struct name *ht,      \
+                                                 struct name##_iter *iter) \
+       {                                                               \
+               htable_delval(&ht->raw, &iter->i);                      \
+       }                                                               \
+       static inline UNNEEDED type *name##_pick(const struct name *ht, \
                                                size_t seed,            \
                                                struct name##_iter *iter) \
        {                                                               \
index 8b7ffca5ea8125ef8ba36a623d989e8aad6fff33..20cd89c5ee956ef0bc2e9dc63d27810b5ca0bf0d 100644 (file)
@@ -131,10 +131,11 @@ void *tal_free(const tal_t *p);
 /**
  * tal_steal - change the parent of a tal-allocated pointer.
  * @ctx: The new parent.
- * @ptr: The tal allocated object to move.
+ * @ptr: The tal allocated object to move, or NULL.
  *
  * This may need to perform an allocation, in which case it may fail; thus
- * it can return NULL, otherwise returns @ptr.
+ * it can return NULL, otherwise returns @ptr.  If @ptr is NULL, this function does
+ * nothing.
  */
 #if HAVE_STATEMENT_EXPR
 /* Weird macro avoids gcc's 'warning: value computed is not used'. */