EC_HTABLE_SET(3)

πŸ’– EC_HTABLE_SET πŸ’–

okay so bestie, welcome to the Libecoli Programmer's Manual ✨ this is the page for ec_htable_set(3) and honestly? she's a baddie. she puts stuff in your hash table. that's it. that's the job. πŸ‘‘


🌸 NAME 🌸

ec_htable_set β€” add or replace an object in the hash table. literally just drop it in there πŸ’…


✨ SYNOPSIS ✨

#include <ecoli/htable.h>

int ec_htable_set(
    struct ec_htable     *htable,   /* The hash table. */
    const void           *key,      /* The key. */
    size_t                key_len,  /* The key length. */
    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_htable_del() or ec_htable_free()).
     */
    ec_htable_elt_free_t  free_cb
);

no cap, that's the whole vibe. you hand her the table, the key, how long that key is, the pointer you wanna stash, and a lil cleanup callback. πŸŽ€


πŸ”₯ RETURN VALUE πŸ”₯

  • 0 on success β€” slay, it worked, main character energy 🌈
  • -1 on error, and errno gets set so you can go find out what went wrong πŸ‘€
⚠️ okay this part matters fr fr: on error, the value you passed in is freed β€” as in free_cb(val) gets called. so do NOT go touching that pointer after a -1, she's gone, she's in her deleted era πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

the whole friend group, go say hi:


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


and that's the page bestie, iykyk 🫢 this was libecoli, dated 2026-06-11, and the page is EC_HTABLE_SET(3) β€” obsessed with her honestly, go set some keys πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from