Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

mkwSys.c File Reference

#include <sys/types.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include "merc.h"
#include "db.h"

Include dependency graph for mkwSys.c:

Go to the source code of this file.

Defines

#define ALLOC_PERM_ALIGN   32
#define chwrite(ch, str)   send_to_char( str, ch )
#define DOUBLE_LOGGING
#define ERR   1
#define IMP_COUNTER(type, start, px)   int px##type() { type * p = start; int n = 0; while( p!=NULL ) { p= p->next; n++; } return n; }
#define IMP_LIST_COUNTERS(type, prefix)   IMP_COUNTER( type, prefix##list, n ) IMP_COUNTER( type, prefix##free, f )
#define MAGIC_CHECKING
#define MAX_MEM_LIST   11
#define MPROGS_INSTALLED
#define object_free   obj_free
#define OK   0
#define rpt(name, n, obj)
#define rpt_dy(name, type)   { int n= n##type(); rpt( name, n, type ); }
#define rptdsd(n, st, sz)   chprintf( ch, "%5d %-28s %5d kB\n\r", n, st, sz )
#define rptf(name, type)   { int n= f##type(); rpt( name, n, type ); }
#define rptsd(st, sz)   chprintf( ch, "%-34s %5d kB\n\r", st, sz )
#define SHOW_ALL_RGSIZES
#define STRSPACE_DEFAULT   (2*4096)
#define STRSPACE_INCREMENT   128

Functions

void * alloc_mem (size_t sMem)
void * alloc_perm (size_t sMem)
void boot_fail (char *module_name)
int chprintf (CHAR_DATA *ch, const char *format,...)
void do_memory (CHAR_DATA *ch, char *argument)
void do_memory_formats (CHAR_DATA *ch, char *argument)
void do_memory_freelists (CHAR_DATA *ch, char *argument)
void do_memory_heap (CHAR_DATA *ch, char *argument)
void do_memory_help (CHAR_DATA *ch, char *argument)
void do_memory_perms (CHAR_DATA *ch, char *argument)
void do_memory_stringspace (CHAR_DATA *ch, char *argument)
void free_mem (void *pMem, size_t sMem)
int has_system_auth (CHAR_DATA *ch)
 IMP_COUNTER (PC_DATA, pcdata_free, f)
size_t rgSize_lookup (size_t size)
char * strspace_alloc ()
void strspace_size_default ()
void strspace_size_increment ()
int strspace_size_read ()
int strspace_size_set (int newsize)
int strswitch (const char *arg,...)
void vinterpret (CHAR_DATA *ch, char *argument,...)

Variables

AFFECT_DATAaffect_free
NOTE_DATAchanges_list
CHAR_DATAchar_free
DESCRIPTOR_DATAdescriptor_free
NOTE_DATAidea_list
int mobile_count
unsigned long nAllocGP [MAX_MEM_LIST] = { 0,0,0,0,0,0,0,0,0,0,0}
int nAllocPerm
NOTE_DATAnews_list
NOTE_DATAnote_list
int nPermBlocks = 0
OBJ_DATAobj_free
PC_DATApcdata_free
NOTE_DATApenalty_list
void * rgFreeList [MAX_MEM_LIST]
const size_t rgSizeList [MAX_MEM_LIST] = { 16, 32, 64, 128, 256, 1024, 2048, 4096, 8192, 16384, 32768-64 }
size_t sAllocPerm = 0
const char separator [] = "-------------------------------------------\n\r"
char * string_space
unsigned strspace_size
const char ver_mkwSys [] = "mkwSys Version 2.01"


Define Documentation

#define ALLOC_PERM_ALIGN   32
 

Definition at line 149 of file mkwSys.c.

Referenced by alloc_perm(), and do_memory_heap().

#define chwrite ch,
str   )     send_to_char( str, ch )
 

Definition at line 171 of file mkwSys.c.

Referenced by do_memory_formats(), do_memory_freelists(), do_memory_heap(), do_memory_help(), do_memory_perms(), and do_memory_stringspace().

#define DOUBLE_LOGGING
 

Definition at line 140 of file mkwSys.c.

#define ERR   1
 

Definition at line 178 of file mkwSys.c.

Referenced by strspace_size_read(), and strspace_size_set().

#define IMP_COUNTER type,
start,
px   )     int px##type() { type * p = start; int n = 0; while( p!=NULL ) { p= p->next; n++; } return n; }
 

Definition at line 322 of file mkwSys.c.

#define IMP_LIST_COUNTERS type,
prefix   )     IMP_COUNTER( type, prefix##list, n ) IMP_COUNTER( type, prefix##free, f )
 

Definition at line 326 of file mkwSys.c.

#define MAGIC_CHECKING
 

Definition at line 168 of file mkwSys.c.

#define MAX_MEM_LIST   11
 

Definition at line 157 of file mkwSys.c.

#define MPROGS_INSTALLED
 

Definition at line 137 of file mkwSys.c.

#define object_free   obj_free
 

Definition at line 174 of file mkwSys.c.

#define OK   0
 

Definition at line 177 of file mkwSys.c.

Referenced by do_memory_stringspace(), strspace_size_read(), and strspace_size_set().

#define rpt name,
n,
obj   ) 
 

Value:

chprintf( ch, "%5d %-14s *%4d Bytes =%6d kB\n\r", \
                                     n, name, sizeof(obj), (n) * sizeof(obj)/1024 )

Definition at line 358 of file mkwSys.c.

Referenced by do_memory_perms().

#define rpt_dy name,
type   )     { int n= n##type(); rpt( name, n, type ); }
 

Definition at line 362 of file mkwSys.c.

Referenced by do_memory_perms().

#define rptdsd n,
st,
sz   )     chprintf( ch, "%5d %-28s %5d kB\n\r", n, st, sz )
 

Definition at line 369 of file mkwSys.c.

Referenced by do_memory_heap().

#define rptf name,
type   )     { int n= f##type(); rpt( name, n, type ); }
 

Definition at line 409 of file mkwSys.c.

Referenced by do_memory_freelists().

#define rptsd st,
sz   )     chprintf( ch, "%-34s %5d kB\n\r", st, sz )
 

Definition at line 366 of file mkwSys.c.

Referenced by do_memory_heap().

#define SHOW_ALL_RGSIZES
 

Definition at line 146 of file mkwSys.c.

#define STRSPACE_DEFAULT   (2*4096)
 

Definition at line 130 of file mkwSys.c.

Referenced by strspace_alloc(), and strspace_size_default().

#define STRSPACE_INCREMENT   128
 

Definition at line 134 of file mkwSys.c.

Referenced by strspace_size_increment().


Function Documentation

void* alloc_mem size_t  sMem  ) 
 

Definition at line 584 of file mkwSys.c.

References alloc_perm(), bug(), MAGIC_NUM, MAX_MEM_LIST, nAllocGP, rgFreeList, and rgSizeList.

Referenced by add_buf(), create_disable_thread(), do_disable(), load_disabled(), load_enhanced_disable(), new_buf(), new_buf_size(), new_descriptor(), new_mem_data(), page_to_char(), page_to_char_bw(), show_list_to_char(), str_dup(), and write_to_buffer().

00585 {
00586     void *pMem;
00587     int iList;
00588 
00589 #ifdef MAGIC_CHECKING
00590      int *magic;
00591      sMem += sizeof(*magic);
00592 #endif
00593 
00594     for ( iList = 0; iList < MAX_MEM_LIST; iList++ )
00595     {
00596         if ( sMem <= rgSizeList[iList] )
00597             break;
00598     }
00599 
00600     if ( iList == MAX_MEM_LIST )
00601     {
00602         bug( "Alloc_mem: size %d too large.", sMem );
00603         //exit( EXIT_FAILURE );
00604     return pMem;
00605     }
00606 
00607     if ( rgFreeList[iList] == NULL )
00608     {
00609         pMem              = alloc_perm( rgSizeList[iList] );
00610         nAllocGP[iList]++;
00611     }
00612     else
00613     {
00614         pMem              = rgFreeList[iList];
00615         rgFreeList[iList] = * ((void **) rgFreeList[iList]);
00616     }
00617 
00618 #ifdef MAGIC_CHECKING
00619     magic = (int *) pMem;
00620     *magic = MAGIC_NUM;
00621     pMem = (void*) (((char*)pMem) + sizeof (*magic));
00622 #endif
00623     return pMem;
00624 }

Here is the call graph for this function:

void* alloc_perm size_t  sMem  ) 
 

Definition at line 634 of file mkwSys.c.

References ALLOC_PERM_ALIGN, bug(), MAX_PERM_BLOCK, nAllocPerm, nPermBlocks, and sAllocPerm.

Referenced by alloc_mem(), load_area(), load_mobiles(), load_mobprogs(), load_objects(), load_old_mob(), load_old_obj(), load_rooms(), load_shops(), load_thread(), new_affect(), new_area(), new_ban(), new_buf(), new_buf_size(), new_char(), new_class(), new_descriptor(), new_exit(), new_extra_descr(), new_gen_data(), new_had(), new_help(), new_load_area(), new_mob_index(), new_mpcode(), new_mprog(), new_note(), new_obj(), new_obj_index(), new_pcdata(), new_reset_data(), new_room_index(), new_shop(), new_social(), and new_vehicle().

00635 {
00636     static int iMemPerm;    
00637     static char *pMemPerm;
00638     void *pMem;
00639 
00640     while ( sMem % ALLOC_PERM_ALIGN != 0 )
00641         sMem++;
00642     if ( sMem > MAX_PERM_BLOCK )
00643     {
00644         bug( "Alloc_perm: %d too large.", sMem );
00645         exit( EXIT_FAILURE );
00646     }
00647 
00648     if ( pMemPerm == NULL || iMemPerm + sMem > MAX_PERM_BLOCK )
00649     {
00650         iMemPerm = 0;
00651         nPermBlocks++;
00652         if ( ( pMemPerm = calloc( 1, MAX_PERM_BLOCK ) ) == NULL )
00653         {
00654             perror( "Alloc_perm" );
00655             exit( EXIT_FAILURE );
00656         }
00657     }
00658 
00659     pMem        = pMemPerm + iMemPerm;
00660     iMemPerm   += sMem;
00661     nAllocPerm += 1;
00662     sAllocPerm += sMem;
00663     return pMem;
00664 }

Here is the call graph for this function:

void boot_fail char *  module_name  ) 
 

Definition at line 226 of file mkwSys.c.

References logf().

Referenced by strspace_alloc(), and strspace_size_increment().

00227 {
00228     logf( "*********************  Reboot by %-11s *********************", module_name );
00229     exit( EXIT_FAILURE );
00230 }

Here is the call graph for this function:

int chprintf CHAR_DATA ch,
const char *  format,
  ...
 

Definition at line 740 of file mkwSys.c.

References MAX_STRING_LENGTH, and write_to_buffer().

Referenced by do_memory_formats(), do_memory_freelists(), do_memory_heap(), do_memory_perms(), and do_memory_stringspace().

00741 {
00742     static char buf[MAX_STRING_LENGTH+1];
00743     va_list arglist;
00744     int nChars= 0;
00745     va_start( arglist, format );
00746     if ( format != NULL && format[0] && ch->desc != NULL )
00747     {
00748         nChars = vsprintf( buf, format, arglist );
00749         assert( nChars <= MAX_STRING_LENGTH );
00750         write_to_buffer( ch->desc, buf, nChars );
00751     }
00752     va_end( arglist );
00753     return nChars;
00754 }

Here is the call graph for this function:

void do_memory CHAR_DATA ch,
char *  argument
 

Definition at line 514 of file mkwSys.c.

References do_memory_formats(), do_memory_freelists(), do_memory_heap(), do_memory_help(), do_memory_perms(), do_memory_stringspace(), and vinterpret().

00515 {
00516     vinterpret( ch, argument, 
00517                 "perms", do_memory_perms,
00518                 "heap", do_memory_heap,
00519                 "freelists", do_memory_freelists,
00520                 "stringspace", do_memory_stringspace,
00521                 "formats", do_memory_formats,
00522                 NULL, do_memory_help );
00523 }

Here is the call graph for this function:

void do_memory_formats CHAR_DATA ch,
char *  argument
 

Definition at line 463 of file mkwSys.c.

References chprintf(), chwrite, newmobs, newobjs, separator, top_mob_index, and top_obj_index.

Referenced by do_memory().

00464 {
00465     chwrite( ch, separator );
00466     chprintf( ch, "Old format mobs: %d\n\rOld format objects: %d\n\r", 
00467              top_mob_index - newmobs, top_obj_index - newobjs ); 
00468     chwrite( ch, separator );
00469 }

Here is the call graph for this function:

void do_memory_freelists CHAR_DATA ch,
char *  argument
 

Definition at line 411 of file mkwSys.c.

References chprintf(), chwrite, MAX_MEM_LIST, rgFreeList, rgSizeList, rptf, and separator.

Referenced by do_memory().

00412 {
00413     int i;
00414     chwrite( ch, separator );
00415     chwrite( ch, "Memory objects waiting to be recycled\n\r");
00416     chwrite( ch, separator );
00417     rptf( "Characters", CHAR_DATA );
00418     rptf( "PCs", PC_DATA ); 
00419     rptf( "Descriptors", DESCRIPTOR_DATA );
00420     rptf( "Objects", OBJ_DATA);
00421     rptf( "Affects", AFFECT_DATA );
00422 
00423     for( i= 0; i<MAX_MEM_LIST; i++)
00424 #ifndef SHOW_ALL_RGSIZES
00425        if( rgFreeList[i] )
00426 #endif
00427        {
00428         void* p;
00429         int n = 0;
00430         for(p= rgFreeList[i]; p != NULL; p= * ((void **) p ) )
00431             n++;
00432         chprintf( ch, "%5d GP blocks of  %6d Bytes =%6d kB\n\r", 
00433             n, rgSizeList[i], n * rgSizeList[i] / 1024);
00434        }
00435     chwrite( ch, separator );
00436 }

Here is the call graph for this function:

void do_memory_heap CHAR_DATA ch,
char *  argument
 

Definition at line 439 of file mkwSys.c.

References ALLOC_PERM_ALIGN, chprintf(), chwrite, MAX_PERM_BLOCK, nAllocPerm, nAllocString, nPermBlocks, rptdsd, rptsd, sAllocPerm, sAllocString, separator, and strspace_size.

Referenced by do_memory().

00440 {
00441     chwrite( ch, separator );
00442     chprintf( ch, "Perm Block size is set to %d kB\n\r", MAX_PERM_BLOCK/1024 );
00443     chprintf( ch, "Object alignment is set to %d Bytes\n\r", ALLOC_PERM_ALIGN );
00444      
00445     rptdsd( nPermBlocks , "Blocks allocated from heap", nPermBlocks * MAX_PERM_BLOCK/1024 );
00446     rptdsd( nAllocPerm, "Permanent objects occupy", sAllocPerm/1024 );
00447     rptsd( "Current alloc_perm() overhead", 
00448             ( nPermBlocks * MAX_PERM_BLOCK - sAllocPerm ) / 1024 );
00449     chwrite( ch, separator );
00450 
00451     rptsd( "String Space allocated at DB boot", strspace_size );
00452     rptdsd( nAllocString, "Strings in string space",  sAllocString/1024 );
00453     rptsd( "Excess string space", strspace_size - sAllocString/1024 );
00454 
00455     chwrite( ch, separator );
00456     rptsd( "Total managed heap memory", nPermBlocks * MAX_PERM_BLOCK/1024 + strspace_size );
00457     chwrite( ch, separator );
00458 }

Here is the call graph for this function:

void do_memory_help CHAR_DATA ch,
char *  argument
 

Definition at line 498 of file mkwSys.c.

References chwrite, and ver_mkwSys.

Referenced by do_memory().

00499 {
00500     chwrite(ch, ver_mkwSys );
00501     chwrite(ch, " copyright (c) 1998 Michael K. Weise\n\r"
00502                 "See home.att.net/~mkw/mudframe.html for more information\n\n\r"
00503                 "usage: memory <command>\n\r\ravailable commands:\n\r"
00504                 "heap                Report heap memory allocated by the memory manager\n\r"
00505                 "perms               Report managed memory objects in use by other modules\n\r"
00506                 "freelists           Report memory objects waiting to be recycled\n\r"
00507                 "stringspace <size>  Set string space size in kB for next reboot\n\r"
00508                 "formats             Report old format prototypes\n\r"
00509                 "?                   This message\n\r"
00510                  );
00511 }

void do_memory_perms CHAR_DATA ch,
char *  argument
 

Definition at line 374 of file mkwSys.c.

References chprintf(), chwrite, MAX_MEM_LIST, mobile_count, nAllocGP, rgSizeList, rpt, rpt_dy, separator, social_count, top_affect, top_area, top_ed, top_exit, top_help, top_mob_index, top_obj_index, top_reset, top_room, and top_shop.

Referenced by do_memory().

00375 {
00376     int i;
00377     chwrite( ch, separator );
00378     chwrite( ch, "{cPermanent memory objects in use{x\n\r");
00379     chwrite( ch, separator );
00380     rpt_dy( "Characters", CHAR_DATA );
00381     rpt( "PCs", nCHAR_DATA() - mobile_count /* should be an accurate shortcut */, PC_DATA ); 
00382     rpt_dy( "Descriptors", DESCRIPTOR_DATA );
00383     rpt( "Mob Prototypes", top_mob_index, MOB_INDEX_DATA );
00384     rpt_dy( "Objects", OBJ_DATA);
00385     rpt( "Obj Prototypes", top_obj_index, OBJ_INDEX_DATA);
00386     rpt( "Extra Descs", top_ed, EXTRA_DESCR_DATA );
00387     rpt( "Affects", top_affect, AFFECT_DATA );
00388     rpt( "Rooms", top_room, ROOM_INDEX_DATA );
00389     rpt( "Exits", top_exit, EXIT_DATA );
00390     rpt( "Shops", top_shop, SHOP_DATA );
00391     rpt( "Areas", top_area, AREA_DATA );
00392     rpt( "Resets", top_reset, RESET_DATA );
00393     rpt( "Help entries", top_help, HELP_DATA );
00394     rpt_dy( "Notes", NOTE_DATA);
00395     rpt( "Socials", social_count, struct social_type );
00396 #ifdef MPROGS_INSTALLED
00397     rpt_dy( "Mob progs", MPROG_CODE )
00398 #endif
00399     for( i= 0; i<MAX_MEM_LIST; i++)
00400 #ifndef SHOW_ALL_RGSIZES
00401        if( nAllocGP[i] )
00402 #endif
00403             chprintf( ch, "%5d GP blocks of  %6d Bytes =%6d kB\n\r", 
00404                     nAllocGP[i], rgSizeList[i], nAllocGP[i] * rgSizeList[i] / 1024);
00405     chwrite( ch, separator );
00406 }

Here is the call graph for this function:

void do_memory_stringspace CHAR_DATA ch,
char *  argument
 

Definition at line 477 of file mkwSys.c.

References chprintf(), chwrite, has_system_auth(), is_number(), MAX_INPUT_LENGTH, OK, one_argument(), and strspace_size_set().

Referenced by do_memory().

00478 {
00479     if( has_system_auth(ch) )
00480     {
00481         char arg[MAX_INPUT_LENGTH];
00482         int sz = 0;
00483         argument= one_argument( argument, arg );
00484         if( is_number( arg ) )
00485             sz= atoi( arg );
00486         if( sz <= 0 || sz > 32000 )
00487         {
00488             chwrite( ch, "Invalid parameter.\n\r" );
00489             return;
00490         }
00491         if( strspace_size_set( sz ) == OK )
00492             chprintf( ch, "String space size for next DB boot set to %d kB.\n\r", sz );
00493         else
00494             chwrite( ch, "Error writing new setting to file.\n\r" );
00495     }
00496 }

Here is the call graph for this function:

void free_mem void *  pMem,
size_t  sMem
 

Definition at line 670 of file mkwSys.c.

References bug(), MAGIC_NUM, MAX_MEM_LIST, rgFreeList, and rgSizeList.

Referenced by add_buf(), destroy_disable_thread(), do_disable(), free_buf(), free_descriptor(), free_string(), show_list_to_char(), show_string(), and write_to_buffer().

00671 {
00672     int iList;
00673 
00674 #ifdef MAGIC_CHECKING
00675     int *magic;
00676   
00677     pMem = (void*) (((char*)pMem) - sizeof (*magic));   
00678     magic = (int *) pMem;
00679   
00680     if (*magic != MAGIC_NUM)
00681     {
00682         bug("Attempt to recyle invalid memory of size %d.",sMem);
00683         bug((char*) pMem + sizeof(*magic),0);
00684         return;
00685     }
00686 
00687     *magic = 0;
00688     sMem += sizeof(*magic);
00689 #endif
00690 
00691     for ( iList = 0; iList < MAX_MEM_LIST; iList++ )
00692     {
00693         if ( sMem <= rgSizeList[iList] )
00694             break;
00695     }
00696 
00697     if ( iList == MAX_MEM_LIST )
00698     {
00699         bug( "Free_mem: size %d too large.", sMem );
00700         exit( EXIT_FAILURE );
00701     }
00702 
00703     * ((void **) pMem) = rgFreeList[iList];
00704     rgFreeList[iList]  = pMem;
00705 
00706     return;
00707 }

Here is the call graph for this function:

int has_system_auth CHAR_DATA ch  ) 
 

Definition at line 311 of file mkwSys.c.

References CREATOR, FALSE, get_trust(), send_to_char(), and TRUE.

Referenced by do_memory_stringspace().

00312 {
00313     if( get_trust( ch ) < CREATOR )
00314     {
00315         send_to_char( "You are not authorized to issue system commands.\n\r", ch );
00316         return FALSE;
00317     }
00318     else
00319         return TRUE;
00320 }

Here is the call graph for this function:

IMP_COUNTER PC_DATA  ,
pcdata_free  ,
 

Definition at line 331 of file mkwSys.c.

References changes_list, idea_list, news_list, note_data::next, note_list, and penalty_list.

00347 {   
00348     NOTE_DATA* p; int n = 0; 
00349     for( p=note_list;p!=NULL; p=p->next) n++; 
00350     for( p=idea_list;p!=NULL; p=p->next) n++; 
00351     for( p=changes_list;p!=NULL; p=p->next) n++; 
00352     for( p=penalty_list;p!=NULL; p=p->next) n++; 
00353     for( p=news_list;p!=NULL; p=p->next) n++; 
00354     return n; 
00355 }

size_t rgSize_lookup size_t  size  ) 
 

Definition at line 564 of file mkwSys.c.

References MAX_MEM_LIST, and rgSizeList.

00565 {
00566     int iList;
00567     size += sizeof( int );  // room needed for integrity marker
00568 
00569     for ( iList = 0; iList < MAX_MEM_LIST; iList++ )
00570     {
00571         if ( size <= rgSizeList[iList] )
00572             return rgSizeList[iList] - sizeof( int );
00573     }
00574     return 0; // size won't fit into any alloc_mem() block
00575 }

char* strspace_alloc  ) 
 

Definition at line 233 of file mkwSys.c.

References boot_fail(), logf(), string_space, STRSPACE_DEFAULT, strspace_size, strspace_size_default(), and strspace_size_read().

Referenced by boot_db().

00234 {
00235     strspace_size_read();
00236     if ( ( string_space = calloc( 1, strspace_size * 1024 ) ) == NULL )
00237     {
00238         logf( "mkwSys.c: Unable to allocate %d kB string space from system.", strspace_size );
00239         if( strspace_size > STRSPACE_DEFAULT )
00240             strspace_size_default();
00241         else
00242             logf( "Increase your system's virtual memory size.", strspace_size );
00243         boot_fail( "mkwSys.c" );
00244     }
00245     return string_space;
00246 }

Here is the call graph for this function:

void strspace_size_default  ) 
 

Definition at line 249 of file mkwSys.c.

References logf(), STRSPACE_DEFAULT, strspace_size, and strspace_size_set().

Referenced by strspace_alloc(), and strspace_size_read().

00250 {
00251     strspace_size_set( STRSPACE_DEFAULT );
00252     logf( "mkwSys.c: String space size reset to program default of %d kB.", strspace_size );
00253 }

Here is the call graph for this function:

void strspace_size_increment  ) 
 

Definition at line 256 of file mkwSys.c.

References boot_fail(), logf(), STRSPACE_INCREMENT, strspace_size, and strspace_size_set().

Referenced by fread_string(), and fread_string_eol().

00257 {
00258     logf( "mkwSys.c: String space size of %d kB did not suffice.", strspace_size );
00259     strspace_size_set( strspace_size + STRSPACE_INCREMENT );
00260     logf( "mkwSys.c: Incrementing string space size to %d kB and rebooting.", strspace_size );
00261     boot_fail( "mkwSys.c" );
00262 }

Here is the call graph for this function:

int strspace_size_read  ) 
 

Definition at line 285 of file mkwSys.c.

References DATPATH, ERR, fread_word(), logf(), OK, str_cmp(), strspace_size, and strspace_size_default().

Referenced by strspace_alloc().

00286 {
00287     FILE* memini= fopen( DATPATH "mkwSys.ini", "r" );
00288     if( memini )
00289     {
00290         strspace_size = 0;
00291         while( str_cmp( fread_word( memini ), "stringspace" ) )
00292             ;
00293         fscanf( memini, " = %u", &strspace_size );
00294         fclose( memini );
00295         if( !strspace_size )
00296         {
00297             logf( "mkwSys.c: String space size not set in mkwSys.ini, using default." );
00298             strspace_size_default();
00299         }
00300         else
00301             return OK;
00302     }
00303     else
00304     {
00305         logf( "mkwSys.c: Unable to open memsize.ini for reading, using default string space size." );
00306         strspace_size_default();
00307     }
00308     return ERR; 
00309 }

Here is the call graph for this function:

int strspace_size_set int  newsize  ) 
 

Definition at line 265 of file mkwSys.c.

References DATPATH, ERR, logf(), and OK.

Referenced by do_memory_stringspace(), strspace_size_default(), and strspace_size_increment().

00266 {
00267   if( newsize > 0 )
00268   {
00269     FILE* memini= fopen( DATPATH "mkwSys.ini", "w" );
00270     if( memini )
00271     {
00272         fprintf( memini, "stringspace = %u\n", newsize );
00273         fclose( memini );
00274         return OK;
00275     }
00276     else
00277     {
00278         logf( "Unable to open mkwSys.ini for writing" );
00279     }
00280   }
00281   return ERR;
00282 }

Here is the call graph for this function:

int strswitch const char *  arg,
  ...
 

Definition at line 526 of file mkwSys.c.

References str_prefix().

00527 {
00528     int i = 0;
00529     char* p;
00530     va_list caselist;
00531     if( arg[0] )
00532     {
00533         va_start( caselist, arg );
00534         while( (p = va_arg( caselist, char* )) != NULL )
00535         {
00536             i++;
00537             if( !str_prefix( arg, p ) )
00538                 return i;
00539         }
00540     }
00541     return 0;
00542 }

Here is the call graph for this function:

void vinterpret CHAR_DATA ch,
char *  argument,
  ...
 

Definition at line 545 of file mkwSys.c.

References MAX_INPUT_LENGTH, one_argument(), and str_prefix().

Referenced by do_memory().

00546 {
00547     char arg[MAX_INPUT_LENGTH];
00548     char* iStr;
00549     DO_FUN *iFun;
00550     va_list caselist;
00551     va_start( caselist, argument );
00552     argument= one_argument( argument, arg );
00553     do 
00554     {
00555         iStr = va_arg( caselist, char* );
00556         iFun = va_arg( caselist, DO_FUN* );
00557     } 
00558     while( iStr != NULL && ( !arg[0] || str_prefix( arg, iStr ) ) );
00559     if( iFun != NULL )
00560         (*iFun)( ch, argument );
00561 }

Here is the call graph for this function:


Variable Documentation

AFFECT_DATA* affect_free
 

Definition at line 214 of file recycle.c.

NOTE_DATA * changes_list
 

Definition at line 59 of file note.c.

Referenced by append_note(), do_unread(), IMP_COUNTER(), load_notes(), note_remove(), parse_note(), and save_notes().

CHAR_DATA* char_free
 

Definition at line 301 of file recycle.c.

DESCRIPTOR_DATA* descriptor_free
 

Definition at line 108 of file recycle.c.

NOTE_DATA * idea_list
 

Definition at line 56 of file note.c.

Referenced by append_note(), do_unread(), IMP_COUNTER(), load_notes(), note_remove(), parse_note(), and save_notes().

int mobile_count
 

Definition at line 202 of file db.c.

unsigned long nAllocGP[MAX_MEM_LIST] = { 0,0,0,0,0,0,0,0,0,0,0}
 

Definition at line 220 of file mkwSys.c.

Referenced by alloc_mem(), and do_memory_perms().

int nAllocPerm
 

Definition at line 222 of file mkwSys.c.

Referenced by alloc_perm(), do_memory_heap(), and interpret().

NOTE_DATA * news_list
 

Definition at line 58 of file note.c.

Referenced by append_note(), do_unread(), IMP_COUNTER(), load_notes(), note_remove(), parse_note(), and save_notes().

NOTE_DATA* note_list
 

Definition at line 86 of file db.c.

int nPermBlocks = 0
 

Definition at line 224 of file mkwSys.c.

Referenced by alloc_perm(), and do_memory_heap().

OBJ_DATA* obj_free
 

Definition at line 247 of file recycle.c.

PC_DATA* pcdata_free
 

Definition at line 388 of file recycle.c.

NOTE_DATA * penalty_list
 

Definition at line 57 of file note.c.

Referenced by append_note(), do_unread(), IMP_COUNTER(), load_notes(), note_remove(), parse_note(), and save_notes().

void * rgFreeList
 

Definition at line 218 of file mkwSys.c.

Referenced by alloc_mem(), do_memory_freelists(), and free_mem().

const size_t rgSizeList = { 16, 32, 64, 128, 256, 1024, 2048, 4096, 8192, 16384, 32768-64 }
 

Definition at line 160 of file mkwSys.c.

Referenced by alloc_mem(), do_memory_freelists(), do_memory_perms(), free_mem(), and rgSize_lookup().

size_t sAllocPerm = 0
 

Definition at line 223 of file mkwSys.c.

Referenced by alloc_perm(), and do_memory_heap().

const char separator[] = "---------------------------------