void LLCALL_C io_append_file_list(io_file_list_t *list, char const *path) { if (list->PathCount == list->PathCapacity) { // need to grow the list of path attributes. size_t new_items = grow_size(list->PathCapacity, PATH_GROW_LIMIT, list->PathCapacity + 1); io_ensure_file_list(list, new_items, list->BlobCapacity); } char const *endp = NULL; uint32_t hash = io_hash_path(path, &endp); size_t nb = endp - path + 1; if (list->BlobCount + nb >= list->BlobCapacity) { size_t new_bytes = grow_size(list->BlobCapacity, BLOB_GROW_LIMIT, list->BlobCount + nb); io_ensure_file_list(list, list->PathCapacity, new_bytes); } size_t index = list->PathCount; uint32_t size = uint32_t(nb-1); // append the basic path properties to the list: list->HashList [index] = hash; list->SizeList [index] = size; list->PathOffset[index] = list->BlobCount; // intern the path string data (including zero byte): memcpy(&list->PathData[list->BlobCount], path, nb); list->BlobCount += uint32_t(nb); list->PathCount += 1; if (nb > list->MaxPathBytes) { // @note: includes the zero byte. list->MaxPathBytes = uint32_t(nb); } }
struct page * dune_page_alloc(void) { struct page *pg; pthread_mutex_lock(&page_mutex); if (SLIST_EMPTY(&pages_free)) { if (grow_size()) { pthread_mutex_unlock(&page_mutex); return NULL; } } pg = SLIST_FIRST(&pages_free); SLIST_REMOVE_HEAD(&pages_free, link); pthread_mutex_unlock(&page_mutex); dune_page_get(pg); return pg; }