4 struct isl_name
*isl_name_alloc(struct isl_ctx
*ctx
, const char *s
)
6 const char *copy
= strdup(s
);
11 name
= isl_alloc_type(ctx
, struct isl_name
);
21 static int isl_name_has_name(const void *entry
, const void *val
)
23 struct isl_name
*name
= (struct isl_name
*)entry
;
24 const char *s
= (const char *)val
;
26 return !strcmp(name
->name
, s
);
29 struct isl_name
*isl_name_get(struct isl_ctx
*ctx
, const char *name
)
31 struct isl_hash_table_entry
*entry
;
34 name_hash
= isl_hash_string(isl_hash_init(), name
);
35 entry
= isl_hash_table_find(ctx
, &ctx
->name_hash
, name_hash
,
36 isl_name_has_name
, name
, 1);
40 return isl_name_copy(ctx
, entry
->data
);
41 entry
->data
= isl_name_alloc(ctx
, name
);
47 struct isl_name
*isl_name_copy(struct isl_ctx
*ctx
, struct isl_name
*name
)
56 static int isl_name_eq(const void *entry
, const void *name
)
61 void isl_name_free(struct isl_ctx
*ctx
, struct isl_name
*name
)
64 struct isl_hash_table_entry
*entry
;
72 name_hash
= isl_hash_string(isl_hash_init(), name
->name
);
73 entry
= isl_hash_table_find(ctx
, &ctx
->name_hash
, name_hash
,
74 isl_name_eq
, name
, 0);
75 isl_assert(ctx
, entry
, return);
76 isl_hash_table_remove(ctx
, &ctx
->name_hash
, entry
);
78 free((char *)name
->name
);