Lines Matching refs:set

41 	struct strset *set = calloc(1, sizeof(*set));  in strset__new()  local
45 if (!set) in strset__new()
48 hash = hashmap__new(strset_hash_fn, strset_equal_fn, set); in strset__new()
52 set->strs_data_max_len = max_data_sz; in strset__new()
53 set->strs_hash = hash; in strset__new()
58 set->strs_data = malloc(init_data_sz); in strset__new()
59 if (!set->strs_data) in strset__new()
62 memcpy(set->strs_data, init_data, init_data_sz); in strset__new()
63 set->strs_data_len = init_data_sz; in strset__new()
64 set->strs_data_cap = init_data_sz; in strset__new()
66 for (off = 0; off < set->strs_data_len; off += strlen(set->strs_data + off) + 1) { in strset__new()
78 return set; in strset__new()
80 strset__free(set); in strset__new()
84 void strset__free(struct strset *set) in strset__free() argument
86 if (IS_ERR_OR_NULL(set)) in strset__free()
89 hashmap__free(set->strs_hash); in strset__free()
90 free(set->strs_data); in strset__free()
91 free(set); in strset__free()
94 size_t strset__data_size(const struct strset *set) in strset__data_size() argument
96 return set->strs_data_len; in strset__data_size()
99 const char *strset__data(const struct strset *set) in strset__data() argument
101 return set->strs_data; in strset__data()
104 static void *strset_add_str_mem(struct strset *set, size_t add_sz) in strset_add_str_mem() argument
106 return libbpf_add_mem(&set->strs_data, &set->strs_data_cap, 1, in strset_add_str_mem()
107 set->strs_data_len, set->strs_data_max_len, add_sz); in strset_add_str_mem()
116 int strset__find_str(struct strset *set, const char *s) in strset__find_str() argument
123 p = strset_add_str_mem(set, len); in strset__find_str()
127 new_off = set->strs_data_len; in strset__find_str()
130 if (hashmap__find(set->strs_hash, new_off, &old_off)) in strset__find_str()
142 int strset__add_str(struct strset *set, const char *s) in strset__add_str() argument
157 p = strset_add_str_mem(set, len); in strset__add_str()
161 new_off = set->strs_data_len; in strset__add_str()
168 err = hashmap__insert(set->strs_hash, new_off, new_off, in strset__add_str()
175 set->strs_data_len += len; /* new unique string, adjust data length */ in strset__add_str()