• Home
  • Raw
  • Download

Lines Matching refs:data

32 static __inline odb_descr_t * odb_to_descr(odb_data_t * data)  in odb_to_descr()  argument
34 return (odb_descr_t *)(((char*)data->base_memory) + data->sizeof_header); in odb_to_descr()
38 static __inline odb_node_t * odb_to_node_base(odb_data_t * data) in odb_to_node_base() argument
40 return (odb_node_t *)(((char *)data->base_memory) + data->offset_node); in odb_to_node_base()
44 static __inline odb_index_t * odb_to_hash_base(odb_data_t * data) in odb_to_hash_base() argument
46 return (odb_index_t *)(((char *)data->base_memory) + in odb_to_hash_base()
47 data->offset_node + in odb_to_hash_base()
48 (data->descr->size * sizeof(odb_node_t))); in odb_to_hash_base()
55 static unsigned int tables_size(odb_data_t const * data, odb_node_nr_t node_nr) in tables_size() argument
61 size += data->offset_node; in tables_size()
67 int odb_grow_hashtable(odb_data_t * data) in odb_grow_hashtable() argument
74 old_file_size = tables_size(data, data->descr->size); in odb_grow_hashtable()
75 new_file_size = tables_size(data, data->descr->size * 2); in odb_grow_hashtable()
77 if (ftruncate(data->fd, new_file_size)) in odb_grow_hashtable()
80 new_map = mremap(data->base_memory, in odb_grow_hashtable()
86 data->base_memory = new_map; in odb_grow_hashtable()
87 data->descr = odb_to_descr(data); in odb_grow_hashtable()
88 data->descr->size *= 2; in odb_grow_hashtable()
89 data->node_base = odb_to_node_base(data); in odb_grow_hashtable()
90 data->hash_base = odb_to_hash_base(data); in odb_grow_hashtable()
91 data->hash_mask = (data->descr->size * BUCKET_FACTOR) - 1; in odb_grow_hashtable()
109 for (pos = 0 ; pos < data->descr->size*BUCKET_FACTOR ; ++pos) in odb_grow_hashtable()
110 data->hash_base[pos] = 0; in odb_grow_hashtable()
113 for (pos = 1; pos < data->descr->current_size; ++pos) { in odb_grow_hashtable()
114 odb_node_t * node = &data->node_base[pos]; in odb_grow_hashtable()
115 size_t index = odb_do_hash(data, node->key); in odb_grow_hashtable()
116 node->next = data->hash_base[index]; in odb_grow_hashtable()
117 data->hash_base[index] = pos; in odb_grow_hashtable()
126 odb->data = NULL; in odb_init()
171 odb_data_t * data; in odb_open() local
179 data = find_samples_data(hash, filename); in odb_open()
180 if (data) { in odb_open()
181 odb->data = data; in odb_open()
182 data->ref_count++; in odb_open()
186 data = xmalloc(sizeof(odb_data_t)); in odb_open()
187 memset(data, '\0', sizeof(odb_data_t)); in odb_open()
188 list_init(&data->list); in odb_open()
189 data->offset_node = sizeof_header + sizeof(odb_descr_t); in odb_open()
190 data->sizeof_header = sizeof_header; in odb_open()
191 data->ref_count = 1; in odb_open()
192 data->filename = xstrdup(filename); in odb_open()
194 data->fd = open(filename, flags, 0644); in odb_open()
195 if (data->fd < 0) { in odb_open()
200 if (fstat(data->fd, &stat_buf)) { in odb_open()
213 nr_node = DEFAULT_NODE_NR(data->offset_node); in odb_open()
215 file_size = tables_size(data, nr_node); in odb_open()
216 if (ftruncate(data->fd, file_size)) { in odb_open()
222 nr_node = (stat_buf.st_size - data->offset_node) / in odb_open()
226 data->base_memory = mmap(0, tables_size(data, nr_node), mmflags, in odb_open()
227 MAP_SHARED, data->fd, 0); in odb_open()
229 if (data->base_memory == MAP_FAILED) { in odb_open()
234 data->descr = odb_to_descr(data); in odb_open()
237 data->descr->size = nr_node; in odb_open()
239 data->descr->current_size = 1; in odb_open()
242 if (nr_node != data->descr->size) { in odb_open()
248 data->hash_base = odb_to_hash_base(data); in odb_open()
249 data->node_base = odb_to_node_base(data); in odb_open()
250 data->hash_mask = (data->descr->size * BUCKET_FACTOR) - 1; in odb_open()
252 list_add(&data->list, &files_hash[hash]); in odb_open()
253 odb->data = data; in odb_open()
257 munmap(data->base_memory, tables_size(data, nr_node)); in odb_open()
259 close(data->fd); in odb_open()
260 free(data->filename); in odb_open()
261 free(data); in odb_open()
262 odb->data = NULL; in odb_open()
269 odb_data_t * data = odb->data; in odb_close() local
271 if (data) { in odb_close()
272 data->ref_count--; in odb_close()
273 if (data->ref_count == 0) { in odb_close()
274 size_t size = tables_size(data, data->descr->size); in odb_close()
275 list_del(&data->list); in odb_close()
276 munmap(data->base_memory, size); in odb_close()
277 if (data->fd >= 0) in odb_close()
278 close(data->fd); in odb_close()
279 free(data->filename); in odb_close()
280 free(data); in odb_close()
281 odb->data = NULL; in odb_close()
289 if (!odb->data) in odb_open_count()
291 return odb->data->ref_count; in odb_open_count()
297 return odb->data->base_memory; in odb_get_data()
303 odb_data_t * data = odb->data; in odb_sync() local
306 if (!data) in odb_sync()
309 size = tables_size(data, data->descr->size); in odb_sync()
310 msync(data->base_memory, size, MS_ASYNC); in odb_sync()