EC_DICT_SET(3)
π EC_DICT_SET(3) β the libecoli era π
okay bestie, so this is a page from the Libecoli Programmer's Manual, and it's all about ec_dict_set from <ecoli/dict.h>. yes we're doing C today. yes it's giving low-level. yes you're gonna slay it. π¦
β¨ NAME β¨
ec_dict_set β put a thing in the hash table, or swap out the thing that's already there. add or replace, your call, she does both. π
πΈ SYNOPSIS πΈ
#include <ecoli/dict.h>
int ec_dict_set(
struct ec_dict *dict, /* The hash table. */
const char *key, /* The key string. Must not be NULL. */
void *val, /* The pointer to be saved in the hash table. */
/*
* An optional pointer to a destructor function called when an object is
* destroyed (ec_dict_del() or ec_dict_free()).
*/
ec_dict_elt_free_t free_cb
);
so like, four things go in:
dictβ the hash table itself. the main character. πkeyβ the key string. and bestie, listen, it must NOT beNULL. no cap, that's a hard rule, don't test her. πvalβ the pointer you want her to hold onto inside the hash table. that's the whole point, that's the vibe. β¨free_cbβ an optional pointer to a destructor function. it gets called whenever an object is destroyed, aka whenec_dict_del()orec_dict_free()comes for it. it's giving cleanup crew energy. π§Ή
π RETURN VALUE π
0 when it works. -1 when it doesn't, and then errno gets set because of course it does. π
okay but here's the tea: on error, the value you passed in gets freed β literally free_cb(val) is called. so don't go touching that pointer afterwards, she's gone, she's been freed, rest in peace. π
π«Ά SEE ALSO π«Ά
the whole friend group, go say hi:
ec_dict_iter(3)ec_dict_has_key(3)ec_dict_free(3)ec_dict_iter_get_val(3)ec_dict_len(3)ec_dict_dup(3)ec_dict_del(3)ec_dict(3)ec_dict_get(3)ec_dict_dump(3)ec_dict_iter_next(3)ec_dict_iter_get_key(3)
π COPYRIGHT π
Copyright (C) 2010-2026 Olivier Matz, Robin Jarry.
and that's the whole page bestie, written by the libecoli girlies, dated 2026-06-11, version libecoli. mwah. go forth and set some dicts. πβ¨π
π¦ where this page comes from
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- fedora 44: libecoli-devel 0.11.7-1.fc44 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms