/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "Licence").
 * You may not use this file except in compliance with the Licence.
 *
 * You can obtain a copy of the licence at RISC OS path @.^.LICENCE
 * or  http://www.riscosdev.com/lanman98/LICENCE.CDDL
 * See the Licence for the specific language governing permissions
 * and limitations under the Licence.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the Licence file. If applicable, add the
 * following below this CDDL HEADER, with the fields enclosed by
 * brackets "[]" replaced with your own identifying information:
 * Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
 
/*
 *   Portions Copyright 1996 Warm Silence Software Ltd.
 */

#include "kernel.h"
#include "stdlib.h"
#include "flex.h"
#include "PGflex.h"

static int held;

void FlexInit(void)
{
    flex_init("", 0, 0);
    //_kernel_register_slotextend(flex_budge);
    held = 0;
}

int FlexAlloc(void **anchor, int size)
{
    return flex_alloc(anchor, size);
}

void FlexFree(void **anchor)
{
    flex_free(anchor);
}

void FlexHold(int hold)
{
    if(hold)
    {
        if(!held)
        {
            free(malloc(16 * 1024));
            //_kernel_register_slotextend(flex_dont_budge);
            held = 1;
        }
    }
    else
    {
        if(held)
        {
            //_kernel_register_slotextend(flex_budge);
            held = 0;
        }
    }
}
