EC_DICT_DUP(3)

πŸ’– EC_DICT_DUP β€” the Libecoli Programmer's Manual ✨

okay bestie, sit down, hydrate, and let's talk about ec_dict_dup(3) β€” she's the clone-maker of the Libecoli dictionary world 🧚


🌸 NAME 🌸

ec_dict_dup β€” Duplicate a hash table. that's it, that's the whole job. she copies. she duplicates. she gives you a twin πŸ‘‘


✨ SYNOPSIS ✨

#include <ecoli/dict.h>

struct ec_dict * ec_dict_dup(
    const struct ec_dict   *dict   /* The hash table. */
);

so you hand her dict, which is just a pointer to the hash table you want cloned, and she hands you back a fresh struct ec_dict *. literally the simplest relationship you'll ever have with a C function πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

A reference counter is shared between the clones of hash tables so that the objects are freed only when the last reference is destroyed.

translation, because this part is IMPORTANT: when you clone a dict, all the clones are lowkey holding hands 🫢 they share one reference counter together. so nothing gets freed until every single last one of the references is gone. the last one standing does the cleanup. main character energy fr fr. so like, don't be out here thinking one ec_dict_free on one clone nukes the whole squad β€” it does NOT, and that's by design πŸ’€βœ¨


🌈 RETURN VALUE 🌈

The duplicated hash table, or NULL on error (errno is set).

so: success = you get your gorgeous duplicate dict. failure = NULL and errno gets set so you can go investigate what went wrong. check that return value bestie, i'm begging πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group, go say hi:

iykyk πŸ’œ


Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.


that's the whole page, no cap πŸ“ this came out of libecoli and the manual page itself is dated 2026-06-11 β€” go forth and duplicate responsibly, mwah πŸ’–πŸ’…

πŸ“¦ where this page comes from