EC_NODE_CLONE(3)

πŸ“¦
version 0.11.7 Β· 5 versions
, in fedora 44

πŸ’– EC_NODE_CLONE β€” okay bestie, let's clone a node πŸ’–

Libecoli Programmer's Manual Β· ec_node_clone(3) Β· come sit with me, this one's short and it's iconic πŸ¦‹


✨ NAME ✨

ec_node_clone β€” clone a grammar node. that's it. that's the whole job. πŸ’…


✨ SYNOPSIS ✨

#include <ecoli/node.h>

struct ec_node * ec_node_clone(
    struct ec_node   *node   /* The node to clone. */
);

look at that signature. clean. no notes. πŸŽ€


✨ DESCRIPTION ✨

okay so real talk, this is not the deep-copy situation you might be picturing. ec_node_clone just takes a reference to the node. that's the move. that's the whole move. ✨

the way that works is: if you later call ec_node_free() on this node, it only decreases the reference. the actual free doesn't happen until the reference count hits 0. and the reference counter? it's initialized to 1 at node creation. 🫢

so like, refcounting. it's giving shared ownership. slay.


✨ RETURN VALUE ✨

  • the pointer to the cloned node β€” and no cap, it's always equal to the parameter 🌈
  • it returns NULL if the parameter was NULL β€” and in that case, nothing is done πŸ™ˆ

✨ SEE ALSO ✨

the whole squad, fr fr πŸ‘‘ β€” go read these too:


Copyright (C) 2010-2026 Olivier Matz, Robin Jarry. πŸ’œ


and that's the page!! this was libecoli, dated 2026-06-11, filed under EC_NODE_CLONE(3) β€” tysm for reading, bestie, go refcount responsibly πŸ§šπŸ’–πŸŒΈ

πŸ“¦ where this page comes from