view kernel/memory.c3 @ 407:9eb1fc6aad6c

Minor improvements
author Windel Bouwman
date Fri, 20 Feb 2015 15:47:54 +0100
parents 0fb6633c42f6
children ad6be5454067
line wrap: on
line source

module memory;

import arch;
import io;

var int ptr;

// Let the heap grow upwards..

function void init()
{
    ptr = 0x80000;
}

function byte* alloc(int size)
{
    var int ptr2;
    ptr2 = ptr;

    io.print2("alloc size ", size);
    io.print2("alloc address ", ptr);

    // Increment new free point:
    ptr = ptr + size;
    return ptr2;
}

function void memcpy(byte* dst, byte* src, int size)
{
    var int i;
    for (i = 0; i < size; i = i + 1)
    {
        *(dst + i) = *(src + i);
    }
}