Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
insert.c File Reference
#include "libft.h"
#include "buckets.h"
Include dependency graph for insert.c:

Functions

bool hashmap_insert (t_hashmap *map, t_key_value *new)
 Inserts a pair into the map, or replaces an existing one.
 

Function Documentation

◆ hashmap_insert()

bool hashmap_insert ( t_hashmap map,
t_key_value new 
)

Inserts a pair into the map, or replaces an existing one.

Appends new to its target bucket chain. If a pair with the same key already exists in that bucket, its value is released through the map's del callback and the existing entry adopts new (see bucket_replace), in which case size is left unchanged.

Note
On success the map takes ownership of new. On failure new is left untouched and ownership remains with the caller.
Parameters
mapPointer to an initialized map (borrowed).
newPair to insert (ownership transferred on success).
Returns
true on success, false on memory allocation failure.
Here is the call graph for this function:
Here is the caller graph for this function: