2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2001-04-14 13:39:14 +02:00
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
2007-09-02 20:11:17 +02:00
|
|
|
|
* Enno Rehling (enno@eressea.de)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
|
*
|
|
|
|
|
* based on:
|
|
|
|
|
*
|
|
|
|
|
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
|
|
|
|
* Atlantis v1.7 Copyright 1996 by Alex Schr<EFBFBD>der
|
|
|
|
|
*
|
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
|
* This program may not be sold or used commercially without prior written
|
|
|
|
|
* permission from the authors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "resolve.h"
|
2005-06-10 00:10:35 +02:00
|
|
|
|
#include "variant.h"
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
typedef struct unresolved {
|
2008-05-17 17:21:17 +02:00
|
|
|
|
void * ptrptr;
|
|
|
|
|
/* address to pass to the resolve-function */
|
2005-06-10 00:10:35 +02:00
|
|
|
|
variant data;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* information on how to resolve the missing object */
|
|
|
|
|
resolve_fun resolve;
|
|
|
|
|
/* function to resolve the unknown object */
|
|
|
|
|
} unresolved;
|
|
|
|
|
|
2007-08-15 08:27:40 +02:00
|
|
|
|
#define BLOCKSIZE 1024
|
|
|
|
|
static unresolved * ur_list;
|
|
|
|
|
static unresolved * ur_begin;
|
|
|
|
|
static unresolved * ur_current;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
void
|
2008-05-17 17:21:17 +02:00
|
|
|
|
ur_add(variant data, void * ptrptr, resolve_fun fun)
|
2007-08-15 08:27:40 +02:00
|
|
|
|
{
|
|
|
|
|
if (ur_list==NULL) {
|
|
|
|
|
ur_list = malloc(BLOCKSIZE*sizeof(unresolved));
|
|
|
|
|
ur_begin = ur_current = ur_list;
|
|
|
|
|
}
|
|
|
|
|
else if (ur_current-ur_begin==BLOCKSIZE-1) {
|
|
|
|
|
ur_begin = malloc(BLOCKSIZE*sizeof(unresolved));
|
|
|
|
|
ur_current->data.v = ur_begin;
|
|
|
|
|
ur_current = ur_begin;
|
|
|
|
|
}
|
|
|
|
|
ur_current->data = data;
|
|
|
|
|
ur_current->resolve = fun;
|
|
|
|
|
ur_current->ptrptr = ptrptr;
|
|
|
|
|
|
|
|
|
|
++ur_current;
|
|
|
|
|
ur_current->resolve = NULL;
|
|
|
|
|
ur_current->data.v = NULL;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
resolve(void)
|
|
|
|
|
{
|
2007-08-15 08:27:40 +02:00
|
|
|
|
unresolved * ur = ur_list;
|
|
|
|
|
while (ur) {
|
|
|
|
|
if (ur->resolve==NULL) {
|
|
|
|
|
ur = ur->data.v;
|
|
|
|
|
free(ur_list);
|
|
|
|
|
ur_list = ur;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2008-05-17 17:21:17 +02:00
|
|
|
|
ur->resolve(ur->data, ur->ptrptr);
|
2007-08-15 08:27:40 +02:00
|
|
|
|
++ur;
|
|
|
|
|
}
|
2008-05-22 12:46:02 +02:00
|
|
|
|
free(ur_list);
|
|
|
|
|
ur_list = NULL;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|