1 /******************************************************************************
2   Copyright (c) 1992, 1995, 1996 Xerox Corporation.  All rights reserved.
3   Portions of this code were written by Stephen White, aka ghond.
4   Use and copying of this software and preparation of derivative works based
5   upon this software are permitted.  Any distribution of this software or
6   derivative works must comply with all applicable United States export
7   control laws.  This software is made available AS IS, and Xerox Corporation
8   makes no warranty about the software, its performance or its conformity to
9   any specification.  Any person obtaining a copy of this software is requested
10   to send their name and post office or electronic mail address to:
11     Pavel Curtis
12     Xerox PARC
13     3333 Coyote Hill Rd.
14     Palo Alto, CA 94304
15     Pavel@Xerox.Com
16  *****************************************************************************/
17 
18 #ifndef Storage_h
19 #define Storage_h 1
20 
21 #include "config.h"
22 #include "structures.h"
23 #include "ref_count.h"
24 
25 typedef enum Memory_Type {
26     M_AST_POOL, M_AST, M_PROGRAM, M_PVAL, M_NETWORK, M_STRING, M_VERBDEF,
27     M_LIST, M_PREP, M_PROPDEF, M_OBJECT_TABLE, M_OBJECT, M_FLOAT,
28     M_STREAM, M_NAMES, M_ENV, M_TASK, M_PATTERN,
29 
30     M_BYTECODES, M_FORK_VECTORS, M_LIT_LIST,
31     M_PROTOTYPE, M_CODE_GEN, M_DISASSEMBLE, M_DECOMPILE,
32 
33     M_RT_STACK, M_RT_ENV, M_BI_FUNC_DATA, M_VM,
34 
35     M_REF_ENTRY, M_REF_TABLE, M_VC_ENTRY, M_VC_TABLE, M_STRING_PTRS,
36     M_INTERN_POINTER, M_INTERN_ENTRY, M_INTERN_HUNK,
37 
38     Sizeof_Memory_Type
39 
40 } Memory_Type;
41 
42 extern char *str_dup(const char *);
43 extern const char *str_ref(const char *);
44 extern Var memory_usage(void);
45 
46 extern void myfree(void *where, Memory_Type type);
47 extern void *mymalloc(unsigned size, Memory_Type type);
48 extern void *myrealloc(void *where, unsigned size, Memory_Type type);
49 
50 static inline void    /* XXX was extern, fix for non-gcc compilers */
free_str(const char * s)51 free_str(const char *s)
52 {
53     if (delref(s) == 0)
54 	myfree((void *) s, M_STRING);
55 }
56 
57 #endif				/* Storage_h */
58 
59 /*
60  * $Log: storage.h,v $
61  * Revision 1.5  1998/12/14 13:19:00  nop
62  * Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims
63  *
64  * Revision 1.4  1998/02/19 07:36:17  nop
65  * Initial string interning during db load.
66  *
67  * Revision 1.3  1997/07/07 03:24:55  nop
68  * Merge UNSAFE_OPTS (r5) after extensive testing.
69  *
70  * Revision 1.2.2.4  1997/05/29 20:47:33  nop
71  * Stupid hack to allow non-gcc compilers to use -Dinline= to make the server
72  * compile.
73  *
74  * Revision 1.2.2.3  1997/05/20 03:01:34  nop
75  * parse_into_words was allocating pointers to strings as strings.  Predictably,
76  * the refcount prepend code was not prepared for this, causing unaligned memory
77  * access on the Alpha.  Added new M_STRING_PTRS allocation class that could
78  * be renamed to something better, perhaps.
79  *
80  * Revision 1.2.2.2  1997/03/21 15:19:24  bjj
81  * add myrealloc interface, inline free_str
82  *
83  * Revision 1.2.2.1  1997/03/20 07:26:04  nop
84  * First pass at the new verb cache.  Some ugly code inside.
85  *
86  * Revision 1.2  1997/03/03 04:19:27  nop
87  * GNU Indent normalization
88  *
89  * Revision 1.1.1.1  1997/03/03 03:45:04  nop
90  * LambdaMOO 1.8.0p5
91  *
92  * Revision 2.1  1996/02/08  06:13:09  pavel
93  * Added M_FLOAT, removed unused M_PI.  Updated copyright notice for 1996.
94  * Release 1.8.0beta1.
95  *
96  * Revision 2.0  1995/11/30  04:55:11  pavel
97  * New baseline version, corresponding to release 1.8.0alpha1.
98  *
99  * Revision 1.7  1992/10/23  23:03:47  pavel
100  * Added copyright notice.
101  *
102  * Revision 1.6  1992/10/21  03:02:35  pavel
103  * Converted to use new automatic configuration system.
104  *
105  * Revision 1.5  1992/10/17  20:53:28  pavel
106  * Global rename of strdup->str_dup, strref->str_ref, vardup->var_dup, and
107  * varref->var_ref, to avoid conflict on systems that provide their own
108  * definition of strdup().
109  *
110  * Revision 1.4  1992/09/14  17:39:30  pjames
111  * Moved db_modification code to db modules.
112  *
113  * Revision 1.3  1992/08/31  22:23:29  pjames
114  * Changed some `char *'s to `const char *'
115  *
116  * Revision 1.2  1992/08/28  16:25:17  pjames
117  * Added memory types for refcount module.  Added `strref()' and `free_str()'.
118  *
119  * Revision 1.1  1992/08/10  16:20:00  pjames
120  * Initial RCS-controlled version
121  */
122