style: noming env_clone
This commit is contained in:
parent
1ab27a6205
commit
98a675e19e
1 changed files with 10 additions and 12 deletions
22
output/src/hashmap/env/env_clone.c
vendored
22
output/src/hashmap/env/env_clone.c
vendored
|
|
@ -1,33 +1,31 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* hashmap_env.h :+: :+: :+: */
|
/* env_clone.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
/* Created: 2023/12/06 11:00:22 by maiboyer #+# #+# */
|
||||||
/* Updated: 2023/12/11 15:24:44 by maiboyer ### ########.fr */
|
/* Updated: 2024/09/19 15:23:50 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
|
|
||||||
#include "me/hashmap/hashmap_env.h"
|
#include "me/hashmap/hashmap_env.h"
|
||||||
|
|
||||||
|
t_error hmap_env_clone(\
|
||||||
|
t_hashmap_env *self, t_error (*clone)(\
|
||||||
t_error hmap_env_clone(t_hashmap_env *self,
|
const t_kv_env *val, void *ctx, t_kv_env *out), \
|
||||||
t_error (*clone)(const t_kv_env *val, void *ctx, t_kv_env *out),
|
void *ctx, t_hashmap_env **out)
|
||||||
void *ctx,
|
|
||||||
t_hashmap_env **out)
|
|
||||||
{
|
{
|
||||||
t_usize bucket_id;
|
t_usize bucket_id;
|
||||||
t_entry_env *cur;
|
t_entry_env *cur;
|
||||||
t_kv_env kv;
|
t_kv_env kv;
|
||||||
t_hashmap_env *ret;
|
t_hashmap_env *ret;
|
||||||
|
|
||||||
bucket_id = 0;
|
bucket_id = 0;
|
||||||
ret = hmap_env_new_with_buckets(self->hfunc, self->cfunc, self->free, self->num_buckets);
|
ret = hmap_env_new_with_buckets(\
|
||||||
|
self->hfunc, self->cfunc, self->free, self->num_buckets);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
while (bucket_id < self->num_buckets)
|
while (bucket_id < self->num_buckets)
|
||||||
|
|
@ -36,7 +34,7 @@ t_error hmap_env_clone(t_hashmap_env *self,
|
||||||
while (cur != NULL)
|
while (cur != NULL)
|
||||||
{
|
{
|
||||||
if (clone(&cur->kv, ctx, &kv))
|
if (clone(&cur->kv, ctx, &kv))
|
||||||
return (hmap_env_free(ret),ERROR);
|
return (hmap_env_free(ret), ERROR);
|
||||||
hmap_env_insert(ret, kv.key, kv.val);
|
hmap_env_insert(ret, kv.key, kv.val);
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue