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

Functions

void bucket_replace (t_list bucket, t_key_value *new, void(*del)(void *))
 Replaces the value of the pair matching new->key within a chain.
 

Function Documentation

◆ bucket_replace()

void bucket_replace ( t_list  bucket,
t_key_value new,
void(*)(void *)  del 
)

Replaces the value of the pair matching new->key within a chain.

Walks the chain and, for the node whose key matches new->key, releases the existing pair (its value through del) and stores new in its place.

Note
Ownership of new is transferred to the matching node. The previously stored pair is freed.
Parameters
bucketHead of the bucket chain to update (borrowed).
newReplacement pair carrying the matching key (ownership transferred).
delOptional destructor applied to the replaced value (may be NULL).
Here is the call graph for this function:
Here is the caller graph for this function: