summaryrefslogtreecommitdiffstats
path: root/lib/untyped.c
blob: e6addbb9621c947668467b07a9b34bd674184ae1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "include/object.h"
#include "api/error.h"

int
ko_untyped_split(objdir_entry_t *target, objdir_entry_t *dest, size_t bytes)
{
    size_t *untyped = ko_entry_data(target);
    if(*untyped <= bytes) return KE_TOOSMALL;

    *untyped -= bytes;
    dest->data = target->data + *untyped;
    *(size_t*)ko_entry_data(dest) = bytes;
    dest->type = KO_MEMORY_UNTYPED;

    return 0;
}