summaryrefslogtreecommitdiffstats
path: root/lib/untyped.c
blob: 8a20f63e7ffd9f47f4bcba27b2dd62b00a93f267 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "include/object.h"
#include "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;
}