/*
 *  Copyright 2009 OpenSourceCodeStewardshipFoundation.org
 *  Licensed under GNU General Public License version 2
 *
 * Author: seanhalle@yahoo.com
 *
 * Created on November 14, 2009, 9:07 PM
 */

#ifndef _VMALLOC_H
#define	_VMALLOC_H

#include <malloc.h>
#include <inttypes.h>
#include "VMS_primitive_data_types.h"

typedef struct _MallocProlog MallocProlog;

struct _MallocProlog
 {
   MallocProlog *nextChunkInFreeList;
   MallocProlog *prevChunkInFreeList;
   MallocProlog *nextHigherInMem;
   MallocProlog *nextLowerInMem;
 };
//MallocProlog

typedef struct
 {
   MallocProlog *firstChunkInFreeList;
   int32         numInList; //TODO not used
 }
FreeListHead;

void *
VMS__malloc( size_t sizeRequested );

void *
VMS__malloc_aligned( size_t sizeRequested );

void
VMS__free( void *ptrToFree );

/*Allocates memory from the external system -- higher overhead
 */
void *
VMS__malloc_in_ext( size_t sizeRequested );

/*Frees memory that was allocated in the external system -- higher overhead
 */
void
VMS__free_in_ext( void *ptrToFree );


MallocProlog *
VMS_ext__create_free_list();

void
VMS_ext__free_free_list( MallocProlog *freeListHead );

#endif