summaryrefslogtreecommitdiff
path: root/src/cache/entry.c
blob: 0f5046228e2d9fe865c5ede76f9bb9abe1b719da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <al/lib.h>

#include "entry.h"

bool cch_entry_get_handle(struct cch_entry *entry, struct cch_handle *handle)
{
    handle->entry = entry;
    handle->pointer = 0;
    handle->wait.disabled = false;
    nn_cond_init(&handle->wait.cond);
    nn_mutex_init(&handle->wait.lock);
    return true;
}

str *cch_entry_get_handler(struct cch_entry *entry)
{
    return &entry->handler->handler;
}

s32 cch_entry_guess_format(struct cch_entry *entry)
{
    return entry->handler->guess_format(entry->handler);
}

void cch_entry_return_handle(struct cch_entry *entry, struct cch_handle *handle)
{
    al_assert(handle->entry == entry);
    handle->entry = NULL;
    nn_mutex_destroy(&handle->wait.lock);
    nn_cond_destroy(&handle->wait.cond);
}

void cch_entry_free(struct cch_entry **entry)
{
    (*entry)->handler->free(&(*entry)->handler);
    (*entry)->backing->free(&(*entry)->backing);
    al_free(*entry);
    *entry = NULL;
}