/* * porthelp.c * * Created on: Jul 21, 2011 * Author: erich * Description: Implements some tools that might come in handy when writing a port */ #include #include #include #include "porthelp.h" typedef struct { handleType type; void *pointer; } HandleListEntry, *PHandleListEntry; volatile HandleListEntry *HandleList; int HandleList_max; int CreateHandleFromPointer(void *p, handleType type) { if (HandleList==NULL) { //Initialize the handlelist HandleList_max=4096 / sizeof(HandleListEntry); //allocate around the size of 4KB HandleList=(PHandleListEntry)malloc(HandleList_max*4096); memset((void *)HandleList, 0, sizeof(HandleListEntry)*256); } //find a empty handle spot, if none are found, relocate (shouldn't happen since ce doesn't open that many handles (of the type provided here), and tends to close them) int i; for (i=1; i0) && (handle