source: golgotha/src/i4/init/init.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.8 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "init/init.hh"
10#include "error/error.hh"
11
12
13i4_init_class *i4_init_class::first_init=0;
14static i4_bool i4_inited=i4_F;
15
16void i4_show_init_list()
17{
18  for (i4_init_class *f=i4_init_class::first_init; f; f=f->next_init)
19    i4_warning("%p\n",f);
20}
21
22void i4_init()
23{
24  I4_ASSERT(!i4_inited, "i4 already initialized");
25
26
27  for (int t=0; t<=I4_INIT_TYPE_OTHER; t++)
28  {
29    i4_init_class *i=i4_init_class::first_init; 
30    for (;i;i=i->next_init)
31      if (i->init_type()==t)
32        i->init();
33
34    if (t==I4_INIT_TYPE_MEMORY_MANAGER)
35      i4_inited=i4_T;   // ok to allocate memory after this stage
36  }
37
38
39}
40
41void i4_uninit()
42{
43  I4_ASSERT(i4_inited, "i4_uninit() without i4_init()");
44
45  for (int t=I4_INIT_TYPE_OTHER; t>=0; t--)
46  {
47    i4_init_class *i=i4_init_class::first_init; 
48    for (;i;i=i->next_init)
49      if (i->init_type()==t)
50        i->uninit();
51  }
52
53  i4_inited=i4_F;
54}
55
56
57i4_init_class::~i4_init_class()
58{
59  i4_init_class *last=0, *i=first_init;
60
61  for (;i && i!=this;)
62  {
63    last=i;
64    i=i->next_init;
65  }
66 
67  if (!i)
68    i4_error("couldn't find init to remove");
69
70  if (last)
71    last->next_init=next_init;
72  else
73    first_init=next_init;
74
75  next_init=0;
76}
77
78
79i4_bool i4_is_initialized()
80{
81  return i4_inited;
82}
83
84i4_init_class::i4_init_class()
85{
86  this->next_init=first_init;
87  first_init=this;
88}
Note: See TracBrowser for help on using the repository browser.