#include <stdio.h>


extern "C"
{
	// create the structure
	__declspec(dllexport) void* Create(int size){
		char *buff = (char*) malloc(size);
		return (void*) buff;
	}

	// delete the structure
	__declspec(dllexport) void Delete(void *handle){
		//printf("Handle: 0x%p Deleted.\r\n", handle);
		free( handle );
	}

	// Set data in the structure
	__declspec(dllexport) void Set(void *handle, int start, char data[], int length){
		char *buff = (char*) handle;
		memcpy(&buff[start], data, length);
	}

	__declspec(dllexport) void Set_Pointer(void *handle, int start, void *data){
		char *buff = (char*) handle;
		long *ptr = (long*) (buff+start);
		// for some reason the address is off by 4 bytes. *Shrug*
		*ptr = (long) (data);
	}

	__declspec(dllexport) void Get(void *handle, int start, int length, char data[]){
		char *buff = (char*) handle;
		memcpy(data, &buff[start], length);
	}

	__declspec(dllexport) void* Get_Pointer(void *handle, int start){
		char *buff = (char*) handle;
		long loc = *(long*) (buff+start);
		return (void*) loc;
	}
}