Changeset 1023
- Timestamp:
- 07/08/07 15:35:54 (1 year ago)
- Files:
-
- 1.8.3/branches/gc/MANIFEST (modified) (3 diffs)
- 1.8.3/branches/gc/Makefile.in (modified) (1 diff)
- 1.8.3/branches/gc/README.GC (added)
- 1.8.3/branches/gc/hdrs/csrimalloc.h (deleted)
- 1.8.3/branches/gc/hdrs/externs.h (modified) (4 diffs)
- 1.8.3/branches/gc/hdrs/flags.h (modified) (1 diff)
- 1.8.3/branches/gc/hdrs/mymalloc.h (modified) (1 diff)
- 1.8.3/branches/gc/hdrs/switches.h (modified) (1 diff)
- 1.8.3/branches/gc/options.h.dist (modified) (1 diff)
- 1.8.3/branches/gc/src/Makefile.in (modified) (22 diffs)
- 1.8.3/branches/gc/src/access.c (modified) (6 diffs)
- 1.8.3/branches/gc/src/atr_tab.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/attrib.c (modified) (5 diffs)
- 1.8.3/branches/gc/src/boolexp.c (modified) (24 diffs)
- 1.8.3/branches/gc/src/bsd.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/bufferq.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/chunk.c (modified) (1 diff)
- 1.8.3/branches/gc/src/command.c (modified) (1 diff)
- 1.8.3/branches/gc/src/comp_h.c (modified) (1 diff)
- 1.8.3/branches/gc/src/comp_w.c (modified) (1 diff)
- 1.8.3/branches/gc/src/comp_w8.c (modified) (1 diff)
- 1.8.3/branches/gc/src/conf.c (modified) (1 diff)
- 1.8.3/branches/gc/src/cque.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/csrimalloc.c (deleted)
- 1.8.3/branches/gc/src/db.c (modified) (6 diffs)
- 1.8.3/branches/gc/src/extmail.c (modified) (11 diffs)
- 1.8.3/branches/gc/src/flags.c (modified) (15 diffs)
- 1.8.3/branches/gc/src/function.c (modified) (1 diff)
- 1.8.3/branches/gc/src/fundb.c (modified) (6 diffs)
- 1.8.3/branches/gc/src/funlist.c (modified) (41 diffs)
- 1.8.3/branches/gc/src/funmath.c (modified) (5 diffs)
- 1.8.3/branches/gc/src/funmisc.c (modified) (1 diff)
- 1.8.3/branches/gc/src/funstr.c (modified) (4 diffs)
- 1.8.3/branches/gc/src/funufun.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/game.c (modified) (1 diff)
- 1.8.3/branches/gc/src/help.c (modified) (4 diffs)
- 1.8.3/branches/gc/src/ident.c (modified) (11 diffs)
- 1.8.3/branches/gc/src/info_slave.c (modified) (3 diffs)
- 1.8.3/branches/gc/src/look.c (modified) (25 diffs)
- 1.8.3/branches/gc/src/malias.c (modified) (4 diffs)
- 1.8.3/branches/gc/src/match.c (modified) (1 diff)
- 1.8.3/branches/gc/src/memcheck.c (deleted)
- 1.8.3/branches/gc/src/move.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/mymalloc.c (modified) (14 diffs)
- 1.8.3/branches/gc/src/mysocket.c (modified) (8 diffs)
- 1.8.3/branches/gc/src/notify.c (modified) (10 diffs)
- 1.8.3/branches/gc/src/pcre.c (modified) (21 diffs)
- 1.8.3/branches/gc/src/player.c (modified) (3 diffs)
- 1.8.3/branches/gc/src/predicat.c (modified) (9 diffs)
- 1.8.3/branches/gc/src/ptab.c (modified) (3 diffs)
- 1.8.3/branches/gc/src/rob.c (modified) (1 diff)
- 1.8.3/branches/gc/src/set.c (modified) (1 diff)
- 1.8.3/branches/gc/src/sort.c (modified) (3 diffs)
- 1.8.3/branches/gc/src/speech.c (modified) (12 diffs)
- 1.8.3/branches/gc/src/strdup.c (deleted)
- 1.8.3/branches/gc/src/strtree.c (modified) (1 diff)
- 1.8.3/branches/gc/src/strutil.c (modified) (4 diffs)
- 1.8.3/branches/gc/src/timer.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/unparse.c (modified) (10 diffs)
- 1.8.3/branches/gc/src/utils.c (modified) (2 diffs)
- 1.8.3/branches/gc/src/version.c (modified) (1 diff)
- 1.8.3/branches/gc/src/wild.c (modified) (5 diffs)
- 1.8.3/branches/gc/src/wiz.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/gc/MANIFEST
r998 r1023 86 86 hdrs/conf.h 87 87 hdrs/copyrite.h 88 hdrs/csrimalloc.h89 88 hdrs/dbdefs.h 90 89 hdrs/dbio.h … … 162 161 src/cque.c 163 162 src/create.c 164 src/csrimalloc.c165 163 src/db.c 166 164 src/destroy.c … … 221 219 src/speech.c 222 220 src/sql.c 223 src/strdup.c224 221 src/strtree.c 225 222 src/strutil.c 1.8.3/branches/gc/Makefile.in
r1019 r1023 22 22 23 23 CCFLAGS=@CFLAGS@ -I.. -I../hdrs 24 LDFLAGS=@LDFLAGS@ 24 LDFLAGS=@LDFLAGS@ -lgc 25 25 CLIBS=@LIBS@ 26 26 INSTALL=@INSTALL@ 1.8.3/branches/gc/hdrs/externs.h
r1017 r1023 207 207 extern char ucbuff[]; 208 208 #define init_compress(f) 0 209 #define compress(s) ((unsigned char *) strdup(s))209 #define compress(s) ((unsigned char *)GC_STRDUP(s)) 210 210 #define uncompress(s) (strcpy(ucbuff, (char *) s)) 211 #define safe_uncompress(s) ( strdup((char *) s))211 #define safe_uncompress(s) (GC_STRDUP((char *) s)) 212 212 #endif 213 213 … … 288 288 void do_look_at(dbref player, const char *name, int key); 289 289 char *decompose_str(char *what); 290 291 /* From memcheck.c */292 void add_check(const char *ref);293 void del_check(const char *ref, const char *filename, int line);294 void list_mem_check(dbref player);295 void log_mem_check(void);296 290 297 291 /* From move.c */ … … 426 420 427 421 /** Unsigned char strdup. Why is this a macro when the others functions? */ 428 #define u_strdup(x) (unsigned char *)strdup((const char *) x) 429 #ifndef HAVE_STRDUP 430 char * 431 strdup(const char *s) 432 __attribute_malloc__; 433 #endif 434 char *mush_strdup(const char *s, const char *check) __attribute_malloc__; 422 #define u_strdup(x) (unsigned char *)GC_STRDUP((const char *) x) 423 #define mush_strdup(s,check) GC_STRDUP((s)) 435 424 436 425 #ifdef HAVE__STRNCOLL … … 555 544 void *mush_calloc(size_t count, size_t size, 556 545 const char *check) __attribute_malloc__; 557 #define mush_realloc(ptr, size, tag) \ 558 mush_realloc_where((ptr), (size), (tag), __FILE__, __LINE__) 559 void *mush_realloc_where(void *restrict ptr, size_t newsize, 560 const char *restrict check, 561 const char *restrict filename, int line); 562 #define mush_free(ptr,tag) mush_free_where((ptr), (tag), __FILE__, __LINE__) 563 void mush_free_where(void *restrict ptr, const char *restrict check, 564 const char *restrict filename, int line); 546 #define mush_realloc(ptr, size, tag) GC_REALLOC((ptr), (size)) 547 #ifndef GC_COLLECT_INSTEAD_OF_FREE 548 #define mush_free(ptr, tag) GC_FREE((ptr)) 549 #else 550 #define mush_free(ptr, tag) (void)0; 551 #endif 565 552 long get_random_long(long low, long high); 566 553 char *fullalias(dbref it); 1.8.3/branches/gc/hdrs/flags.h
r950 r1023 182 182 183 183 184 /* Flags can be in the flaglist multiple times, thanks to aliases. Keep185 a reference count of how many times, and free memory when it goes to 0. */186 #define F_REF_MASK 0xFF000000U /**< Mask to get the reference count */187 #define F_REF_NOT 0x00FFFFFFU /**< Everything but */188 #define FLAG_REF(r) (((r) & F_REF_MASK) >> 30)189 #define ZERO_FLAG_REF(r) ((r) & F_REF_NOT)190 #define INCR_FLAG_REF(r) ((r) + (1 << 30))191 #define DECR_FLAG_REF(r) ((r) - (1 << 30))192 193 194 184 /*-------------------------------------------------------------------------- 195 185 * Powers table 1.8.3/branches/gc/hdrs/mymalloc.h
r974 r1023 8 8 #include "options.h" 9 9 10 #if (MALLOC_PACKAGE == 1) 11 #define CSRI 12 #elif (MALLOC_PACKAGE == 2) 13 #include <stdlib.h> 14 #define CSRI 15 #define CSRI_TRACE 16 #define CSRI_PROFILESIZES 17 #define CSRI_DEBUG 18 #include "csrimalloc.h" 19 #endif 10 /* GC functions */ 11 #include <gc.h> 20 12 21 13 typedef struct slab slab; 1.8.3/branches/gc/hdrs/switches.h
r974 r1023 154 154 #define SWITCH_YES 151 155 155 #define SWITCH_ZONE 152 156 #endif /* SWITCHES_H */156 #endif /* SWITCHES_H */ 1.8.3/branches/gc/options.h.dist
r838 r1023 25 25 26 26 /*---------------- Internals with many options ------------------------*/ 27 28 /* Malloc package options */29 /* malloc() is the routine that allocates memory while the MUSH is30 * running. Because mallocs vary a lot from operating system to operating31 * system, you can choose to use one of the mallocs we provide instead of32 * your operating system's malloc.33 * Set the value of MALLOC_PACKAGE to one of these values:34 * 0 -- Use my system's malloc. Required for Win32 systems.35 * Recommended for FreeBSD, Linux, Mac OS X/Darwin, and other OS's36 * where you think the malloc routines are efficient and debugged.37 * In other words, pretty much any fairly current OS releases.38 * 1 -- Use the CSRI malloc package in normal mode.39 * Recomended for ancient OS releases. On anything modern, you'll want40 * the system malloc (Option 0).41 * 2 -- Use the CSRI malloc package in debug mode.42 * Only use this if you're tracking down memory leaks. Don't use43 * for a production MUSH - it's slow.44 * 3, 4, 5, 6 -- Same as 0, kept for compatibility.45 */46 #define MALLOC_PACKAGE 047 27 48 28 /* What type of attribute compression should the MUSH use? 1.8.3/branches/gc/src/Makefile.in
r1019 r1023 19 19 funmath.c funmisc.c funstr.c funtime.c funufun.c game.c help.c \ 20 20 htab.c ident.c local.c lock.c log.c look.c malias.c markup.c \ 21 match.c m emcheck.c move.c mycrypt.c mymalloc.c mysocket.c \22 my rlimit.c myssl.c notify.c parse.c pcre.c player.c plyrlist.c \23 pr edicat.c privtab.c info_master.c ptab.c rob.c services.c \24 s et.c shs.c sig.c sort.c speech.c sql.c strdup.c strtree.c \25 strutil.c tables.c timer.c unparse.c utils.c version.c wait.c \26 w arnings.c wild.c wiz.c21 match.c move.c mycrypt.c mymalloc.c mysocket.c myrlimit.c \ 22 myssl.c notify.c parse.c pcre.c player.c plyrlist.c predicat.c \ 23 privtab.c info_master.c ptab.c rob.c services.c set.c shs.c \ 24 sig.c sort.c speech.c sql.c strtree.c strutil.c tables.c \ 25 timer.c unparse.c utils.c version.c wait.c warnings.c wild.c \ 26 wiz.c 27 27 28 28 … … 34 34 funmath.o funmisc.o funstr.o funtime.o funufun.o game.o help.o \ 35 35 htab.o ident.o local.o lock.o log.o look.o malias.o markup.o \ 36 match.o m emcheck.o move.o mycrypt.o mymalloc.o mysocket.o \37 my rlimit.o myssl.o notify.o parse.o pcre.o player.o plyrlist.o\36 match.o move.o mycrypt.o mymalloc.o mysocket.o myrlimit.o \ 37 myssl.o notify.o parse.o pcre.o player.o plyrlist.o \ 38 38 info_master.o predicat.o privtab.o ptab.o rob.o services.o \ 39 set.o shs.o sig.o sort.o speech.o sql.o str dup.o strtree.o \40 strutil.o tables.o timer.o unparse.o utils.o version.o wait.o \41 w arnings.o wild.o wiz.o39 set.o shs.o sig.o sort.o speech.o sql.o strtree.o strutil.o \ 40 tables.o timer.o unparse.o utils.o version.o wait.o warnings.o \ 41 wild.o wiz.o 42 42 43 43 # This is a dummy target, in case you type 'make' in the source … … 56 56 # We recompile mysocket.c instead of reusing mysocket.o because we 57 57 # want to do some error handing differently for info_slave. 58 info_slave: info_slave.c ident.o s trdup.o sig.o wait.o mysocket.c ../hdrs/lookup.h58 info_slave: info_slave.c ident.o sig.o wait.o mysocket.c ../hdrs/lookup.h 59 59 @echo "Making info_slave." 60 60 $(CC) $(CCFLAGS) -c info_slave.c 61 61 $(CC) $(CCFLAGS) -DINFOSLAVE -o info_slave info_slave.o \ 62 ident.o s trdup.o sig.o wait.o mysocket.c $(LDFLAGS) $(LIBS)63 64 SSL_SLAVE_OBJS = s trdup.o sig.o mymalloc.o mysocket.o myssl.o notify.o myrlimit.o strutil.o ident.o utils.o62 ident.o sig.o wait.o mysocket.c $(LDFLAGS) $(LIBS) 63 64 SSL_SLAVE_OBJS = sig.o mymalloc.o mysocket.o myssl.o notify.o myrlimit.o strutil.o ident.o utils.o 65 65 ssl_slave: ssl_slave.c $(SSL_SLAVE_OBJS) 66 66 @echo "Making ssl_slave." … … 285 285 bsd.o: ../hdrs/mushtype.h 286 286 bsd.o: ../hdrs/htab.h 287 bsd.o: ../hdrs/wait.h288 287 bsd.o: ../hdrs/externs.h 289 288 bsd.o: ../hdrs/compile.h … … 309 308 bsd.o: ../hdrs/mysocket.h 310 309 bsd.o: ../hdrs/ident.h 310 bsd.o: ../hdrs/wait.h 311 311 bsd.o: ../hdrs/lookup.h 312 312 bsd.o: ../hdrs/strtree.h … … 477 477 conf.o: ../hdrs/help.h 478 478 conf.o: ../hdrs/function.h 479 conf.o: ../hdrs/mymalloc.h 479 480 cque.o: ../hdrs/copyrite.h 480 481 cque.o: ../config.h … … 781 782 fundb.o: ../hdrs/attrib.h 782 783 fundb.o: ../hdrs/function.h 784 fundb.o: ../hdrs/mymalloc.h 783 785 funlist.o: ../hdrs/copyrite.h 784 786 funlist.o: ../config.h … … 842 844 funmath.o: ../hdrs/sort.h 843 845 funmath.o: ../hdrs/parse.h 846 funmath.o: ../hdrs/mymalloc.h 844 847 funmath.o: lmathtab.c 845 848 funmisc.o: ../hdrs/copyrite.h … … 869 872 funmisc.o: ../hdrs/game.h 870 873 funmisc.o: ../hdrs/attrib.h 874 funmisc.o: ../hdrs/mymalloc.h 871 875 funmisc.o: ../hdrs/ansi.h 872 876 funstr.o: ../hdrs/copyrite.h … … 894 898 funstr.o: ../hdrs/boolexp.h 895 899 funstr.o: ../hdrs/sort.h 900 funstr.o: ../hdrs/mymalloc.h 896 901 funtime.o: ../hdrs/copyrite.h 897 902 funtime.o: ../config.h … … 972 977 game.o: ../hdrs/wait.h 973 978 game.o: ../hdrs/ansi.h 979 game.o: ../hdrs/mymalloc.h 974 980 help.o: ../config.h 975 981 help.o: ../hdrs/conf.h … … 1049 1055 local.o: ../hdrs/command.h 1050 1056 local.o: ../hdrs/switches.h 1057 local.o: ../hdrs/lock.h 1058 local.o: ../hdrs/boolexp.h 1051 1059 lock.o: ../hdrs/copyrite.h 1052 1060 lock.o: ../config.h … … 1118 1126 look.o: ../hdrs/parse.h 1119 1127 look.o: ../hdrs/privtab.h 1128 look.o: ../hdrs/mymalloc.h 1120 1129 look.o: ../hdrs/log.h 1121 1130 malias.o: ../config.h … … 1183 1192 match.o: ../hdrs/match.h 1184 1193 match.o: ../hdrs/parse.h 1185 memcheck.o: ../config.h 1186 memcheck.o: ../hdrs/conf.h 1187 memcheck.o: ../hdrs/copyrite.h 1188 memcheck.o: ../options.h 1189 memcheck.o: ../hdrs/mushtype.h 1190 memcheck.o: ../hdrs/htab.h 1191 memcheck.o: ../hdrs/externs.h 1192 memcheck.o: ../hdrs/compile.h 1193 memcheck.o: ../hdrs/dbdefs.h 1194 memcheck.o: ../hdrs/mushdb.h 1195 memcheck.o: ../hdrs/flags.h 1196 memcheck.o: ../hdrs/ptab.h 1197 memcheck.o: ../hdrs/chunk.h 1198 memcheck.o: ../confmagic.h 1199 memcheck.o: ../hdrs/pcre.h 1200 memcheck.o: ../hdrs/mymalloc.h 1201 memcheck.o: ../hdrs/log.h 1194 match.o: ../hdrs/mymalloc.h 1202 1195 move.o: ../hdrs/copyrite.h 1203 1196 move.o: ../config.h … … 1363 1356 pcre.o: ../config.h 1364 1357 pcre.o: ../hdrs/pcre.h 1358 pcre.o: ../hdrs/mymalloc.h 1359 pcre.o: ../options.h 1365 1360 pcre.o: ../confmagic.h 1366 1361 player.o: ../hdrs/copyrite.h … … 1479 1474 ptab.o: ../confmagic.h 1480 1475 ptab.o: ../hdrs/pcre.h 1476 ptab.o: ../hdrs/mymalloc.h 1481 1477 rob.o: ../config.h 1482 1478 rob.o: ../hdrs/copyrite.h … … 1566 1562 sort.o: ../hdrs/switches.h 1567 1563 sort.o: ../hdrs/sort.h 1564 sort.o: ../hdrs/mymalloc.h 1568 1565 speech.o: ../hdrs/copyrite.h 1569 1566 speech.o: ../config.h … … 1590 1587 speech.o: ../hdrs/game.h 1591 1588 speech.o: ../hdrs/sort.h 1589 speech.o: ../hdrs/mymalloc.h 1592 1590 sql.o: ../hdrs/copyrite.h 1593 1591 sql.o: ../config.h … … 1611 1609 sql.o: ../hdrs/function.h 1612 1610 sql.o: ../hdrs/ansi.h 1613 strdup.o: ../config.h1614 strdup.o: ../hdrs/conf.h1615 strdup.o: ../hdrs/copyrite.h1616 strdup.o: ../options.h1617 strdup.o: ../hdrs/mushtype.h1618 strdup.o: ../hdrs/htab.h1619 strdup.o: ../hdrs/mymalloc.h1620 strdup.o: ../confmagic.h1621 1611 strtree.o: ../hdrs/copyrite.h 1622 1612 strtree.o: ../config.h … … 1634 1624 strtree.o: ../confmagic.h 1635 1625 strtree.o: ../hdrs/pcre.h 1626 strtree.o: ../hdrs/mymalloc.h 1636 1627 strtree.o: ../hdrs/strtree.h 1637 1628 strutil.o: ../config.h … … 1681 1672 timer.o: ../hdrs/parse.h 1682 1673 timer.o: ../hdrs/attrib.h 1674 timer.o: ../hdrs/mymalloc.h 1683 1675 unparse.o: ../hdrs/copyrite.h 1684 1676 unparse.o: ../config.h … … 1702 1694 unparse.o: ../hdrs/pueblo.h 1703 1695 unparse.o: ../hdrs/parse.h 1696 unparse.o: ../hdrs/mymalloc.h 1704 1697 utils.o: ../hdrs/copyrite.h 1705 1698 utils.o: ../config.h 1.8.3/branches/gc/src/access.c
r945 r1023 117 117 (const char *host, const dbref who, const int can, const int cant, 118 118 const char *comment); 119 static void free_access_list(void);120 119 121 120 static int … … 126 125 struct access *tmp; 127 126 128 tmp = (struct access *) mush_malloc(sizeof(struct access), "struct_access");127 tmp = GC_MALLOC(sizeof(struct access)); 129 128 if (!tmp) 130 129 return 0; … … 172 171 * entries 173 172 */ 174 free_access_list();173 access_top = NULL; 175 174 } 176 175 access_top = NULL; … … 501 500 struct access *tmp; 502 501 503 tmp = (struct access *) mush_malloc(sizeof(struct access), "struct_access");502 tmp = GC_MALLOC(sizeof(struct access)); 504 503 if (!tmp) 505 504 return 0; … … 564 563 if (strcasecmp(pattern, ap->host) == 0) { 565 564 n++; 566 mush_free(ap, "struct_access");567 565 if (prev) 568 566 prev->next = next; … … 576 574 577 575 return n; 578 }579 580 /* Free the entire access list */581 static void582 free_access_list(void)583 {584 struct access *ap, *next;585 ap = access_top;586 while (ap) {587 next = ap->next;588 mush_free((Malloc_t) ap, "struct_access");589 ap = next;590 }591 access_top = NULL;592 576 } 593 577 1.8.3/branches/gc/src/atr_tab.c
r905 r1023 213 213 return; 214 214 } 215 AL_NAME(ap) = strdup(name);215 AL_NAME(ap) = GC_STRDUP(name); 216 216 ap->data = NULL_CHUNK_REFERENCE; 217 217 } … … 311 311 /* Ok, take it out and put it back under the new name */ 312 312 ptab_delete(&ptab_attrib, old); 313 /* This causes a slight memory leak if you rename an attribute 314 added via /access. But that doesn't happen often. Will fix 315 someday. */ 316 AL_NAME(ap) = strdup(newname); 313 AL_NAME(ap) = GC_STRDUP(newname); 317 314 ptab_insert_one(&ptab_attrib, newname, ap); 318 315 notify_format(player, 1.8.3/branches/gc/src/attrib.c
r967 r1023 556 556 } 557 557 root->data = chunk_create(t, u_strlen(t), 0); 558 free(t);559 558 } 560 559 } else { … … 577 576 578 577 ptr->data = chunk_create(t, u_strlen(t), derefs); 579 free(t);580 578 581 579 if (*s == '$') … … 654 652 mush_panic(T("Unable to allocate memory in atr_add()!")); 655 653 root->data = chunk_create(t, u_strlen(t), 0); 656 free(t);657 654 } 658 655 } else … … 690 687 } 691 688 ptr->data = chunk_create(t, u_strlen(t), 0); 692 free(t);693 689 694 690 if (*s == '$') … … 1542 1538 while (used_list) { 1543 1539 UsedAttr *temp = used_list->next; 1544 mush_free(used_list, "used_attr");1545 1540 used_list = temp; 1546 1541 } 1.8.3/branches/gc/src/boolexp.c
r985 r1023 265 265 const char *s) __attribute_malloc__; 266 266 static void skip_whitespace(void); 267 static void free_bool(struct boolexp_node *b);268 267 static struct boolexp_node *test_atr(char *s, char c); 269 268 static struct boolexp_node *parse_boolexp_R(void); … … 278 277 static int check_attrib_lock(dbref player, dbref target, 279 278 const char *atrname, const char *str); 280 static void free_boolexp_node(struct boolexp_node *b);281 279 static int gen_label_id(struct bvm_asm *a); 282 280 static void append_insn(struct bvm_asm *a, bvm_opcode op, int arg, … … 292 290 static void optimize_bvm_asm(struct bvm_asm *a); 293 291 static boolexp emit_bytecode(struct bvm_asm *a, int derefs); 294 static void free_bvm_asm( struct bvm_asm *a);292 static void free_bvm_asm(void); 295 293 #ifdef DEBUG_BYTECODE 296 294 static int sizeof_boolexp_node(struct boolexp_node *b); … … 325 323 326 324 len = chunk_len(b); 327 bytecode = mush_malloc(len, "boolexp.bytecode");325 bytecode = GC_MALLOC_ATOMIC(len); 328 326 chunk_fetch(b, bytecode, len); 329 327 return bytecode; … … 611 609 } 612 610 } 613 free((Malloc_t) orig);614 611 } 615 612 break; … … 622 619 } 623 620 done: 624 mush_free(bytecode, "boolexp.bytecode");625 621 return r; 626 622 } … … 824 820 a->name = st_insert(strupper(name), &atr_names); 825 821 if (!a->name) { 826 mush_free(a, "boolatr");827 822 return NULL; 828 823 } … … 849 844 850 845 return b; 851 }852 853 /** Frees a boolexp node.854 * \param b the boolexp_node to deallocate.855 */856 static void857 free_bool(struct boolexp_node *b)858 {859 mush_free(b, "boolexp.node");860 }861 862 /** Free a boolexp ast node.863 * This function frees a boolexp, including all subexpressions,864 * recursively.865 * \param b boolexp to free.866 */867 static void868 free_boolexp_node(struct boolexp_node *b)869 {870 if (b) {871 switch (b->type) {872 case BOOLEXP_AND:873 case BOOLEXP_OR:874 free_boolexp_node(b->data.sub.a);875 free_boolexp_node(b->data.sub.b);876 free_bool(b);877 break;878 case BOOLEXP_NOT:879 free_boolexp_node(b->data.n);880 free_bool(b);881 break;882 case BOOLEXP_CONST:883 case BOOLEXP_CARRY:884 case BOOLEXP_IS:885 case BOOLEXP_OWNER:886 case BOOLEXP_BOOL:887 free_bool(b);888 break;889 case BOOLEXP_IND:890 if (b->data.ind_lock)891 st_delete(b->data.ind_lock, &lock_names);892 free_bool(b);893 break;894 case BOOLEXP_ATR:895 case BOOLEXP_EVAL:896 case BOOLEXP_FLAG:897 if (b->data.atr_lock) {898 if (b->data.atr_lock->name)899 st_delete(b->data.atr_lock->name, &atr_names);900 mush_free((Malloc_t) b->data.atr_lock, "boolatr");901 }902 free_bool(b);903 break;904 }905 }906 846 } 907 847 … … 979 919 } else { 980 920 /* Ooog. Dealing with a malformed lock in the database. */ 981 free_bool(b);982 921 return NULL; 983 922 } … … 999 938 if (b->thing == NOTHING) { 1000 939 notify_format(parse_player, T("I don't see %s here."), tbuf1); 1001 free_bool(b);1002 940 return NULL; 1003 941 } else if (b->thing == AMBIGUOUS) { 1004 942 notify_format(parse_player, T("I don't know which %s you mean!"), tbuf1); 1005 free_bool(b);1006 943 return NULL; 1007 944 } else { … … 1026 963 skip_whitespace(); 1027 964 if (b == NULL || *parsebuf++ != ')') { 1028 free_boolexp_node(b);1029 965 return NULL; 1030 966 } else { … … 1076 1012 t = parse_boolexp_R(); 1077 1013 if (t == NULL) { 1078 free_boolexp_node(b2);1079 1014 return NULL; 1080 1015 } else { 1081 1016 b2->thing = t->thing; 1082 free_boolexp_node(t);1083 1017 return b2; 1084 1018 } … … 1099 1033 t = parse_boolexp_R(); 1100 1034 if (t == NULL) { 1101 free_boolexp_node(b2);1102 1035 return NULL; 1103 1036 } else { 1104 1037 b2->thing = t->thing; 1105 free_boolexp_node(t);1106 1038 return b2; 1107 1039 } … … 1122 1054 t = parse_boolexp_R(); 1123 1055 if (t == NULL) { 1124 free_boolexp_node(b2);1125 1056 return NULL; 1126 1057 } else { 1127 1058 b2->thing = t->thing; 1128 free_boolexp_node(t);1129 1059 return b2; 1130 1060 } … … 1145 1075 t = parse_boolexp_R(); 1146 1076 if (t == NULL) { 1147 free_boolexp_node(b2);1148 1077 return NULL; 1149 1078 } 1150 1079 b2->thing = t->thing; 1151 free_boolexp_node(t);1152 1080 if (*parsebuf == '/') { 1153 1081 char tbuf1[BUFFER_LEN], *p; … … 1166 1094 upcasestr(tbuf1); 1167 1095 if (!good_atr_name(tbuf1)) { 1168 free_boolexp_node(b2);1169 1096 return NULL; 1170 1097 } 1171 1098 m = match_lock(tbuf1); 1172 b2->data.ind_lock = st_insert(m ? m : tbuf1, &lock_names);1099 b2->data.ind_lock = GC_STRDUP(m ? m : tbuf1); 1173 1100 } else { 1174 b2->data.ind_lock = st_insert(parse_ltype, &lock_names);1101 b2->data.ind_lock = GC_STRDUP(parse_ltype); 1175 1102 } 1176 1103 return b2; … … 1190 1117 b2->type = BOOLEXP_NOT; 1191 1118 if ((b2->data.n = parse_boolexp_F()) == NULL) { 1192 free_boolexp_node(b2);1193 1119 return NULL; 1194 1120 } else … … 1215 1141 b2->data.sub.a = b; 1216 1142 if ((b2->data.sub.b = parse_boolexp_T()) == NULL) { 1217 free_boolexp_node(b2);1218 1143 return NULL; 1219 1144 } else { … … 1242 1167 b2->data.sub.a = b; 1243 1168 if ((b2->data.sub.b = parse_boolexp_E()) == NULL) { 1244 free_boolexp_node(b2);1245 1169 return NULL; 1246 1170 } else { … … 1441 1365 */ 1442 1366 static void 1443 free_bvm_asm(struct bvm_asm *a) 1444 { 1445 struct bvm_strnode *s, *tmp2; 1446 1447 if (!a) 1448 return; 1449 1367 free_bvm_asm(void) 1368 { 1450 1369 slab_destroy(bvm_asmnode_slab); 1451 1370 bvm_asmnode_slab = NULL; 1452 1453 for (s = a->shead; s; s = tmp2) {1454 tmp2 = s->next;1455 mush_free(s->s, "bvm.string");1456 mush_free(s, "bvm.strnode");1457 }1458 mush_free(a, "bvm.asm");1459 1371 } 1460 1372 … … 1648 1560 1649 1561 b = chunk_create(bytecode, len, derefs); 1650 mush_free(bytecode, "boolexp.bytecode");1651 1562 return b; 1652 1563 } … … 1677 1588 bvasm = generate_bvm_asm(ast); 1678 1589 if (!bvasm) { 1679 free_boolexp_node(ast);1680 1590 return TRUE_BOOLEXP; 1681 1591 } … … 1687 1597 print_bytecode(bytecode); 1688 1598 #endif 1689 free_boolexp_node(ast); 1690 free_bvm_asm(bvasm); 1599 free_bvm_asm(); 1691 1600 return bytecode; 1692 1601 } … … 1742 1651 *bp = '\0'; 1743 1652 restore_global_regs("check_attrib_lock_save", preserve); 1744 free(asave);1745 1653 1746 1654 return !strcasecmp(buff, str); 1.8.3/branches/gc/src/bsd.c
r1017 r1023 402 402 bool detach_session = 1; 403 403 404 GC_INIT(); 405 GC_enable_incremental(); 406 404 407 /* disallow running as root on unix. 405 408 * This is done as early as possible, before translation is initialized. … … 1158 1161 safe_str(socket_ident, tbuf1, &bp); 1159 1162 safe_chr('@', tbuf1, &bp); 1160 free(socket_ident);1161 1163 } 1162 1164 } 1.8.3/branches/gc/src/bufferq.c
r905 r1023 123 123 BUFFERQ *bq; 124 124 int bytes = lines * (BUFFER_LEN + BUFFERQLINEOVERHEAD); 125 bq = mush_malloc(sizeof(BUFFERQ), "bufferq");126 bq->buffer = mush_malloc(bytes, "bufferq.buffer");125 bq = GC_MALLOC(sizeof(BUFFERQ)); 126 bq->buffer = GC_MALLOC_ATOMIC(bytes); 127 127 *bq->buffer = '\0'; 128 128 bq->buffer_end = bq->buffer; … … 171 171 } 172 172 bufflen = bq->buffer_end - bq->buffer; 173 newbuff = realloc(bq->buffer, bytes);173 newbuff = GC_REALLOC(bq->buffer, bytes); 174 174 if (newbuff) { 175 175 bq->buffer = newbuff; 1.8.3/branches/gc/src/chunk.c
r918 r1023 1519 1519 do_rawlog(LT_TRACE, "CHUNK: realloc()ing region array"); 1520 1520 #endif 1521 regions = (Region *) realloc(regions, region_array_len * sizeof(Region));1521 regions = GC_REALLOC(regions, region_array_len * sizeof(Region)); 1522 1522 if (!regions) 1523 1523 mush_panic("chunk: region array realloc failure"); 1.8.3/branches/gc/src/command.c
r964 r1023 1838 1838 if (!code) 1839 1839 return 1; 1840 add_check("hook.code");1841 1840 1842 1841 save_global_regs("run_hook", origregs); 1.8.3/branches/gc/src/comp_h.c
r967 r1023 95 95 /* Part 2 - Actually get around to compressing the data... */ 96 96 p = (const unsigned char *) s; 97 b = buf = (unsigned char *) malloc(needed_length);97 b = buf = GC_MALLOC_ATOMIC(needed_length); 98 98 stage = 0; 99 99 bits = 0; 1.8.3/branches/gc/src/comp_w.c
r911 r1023 208 208 return; 209 209 } 210 words[i] = malloc(wordpos);210 words[i] = GC_MALLOC_ATOMIC(wordpos); 211 211 212 212 if (!words[i]) 1.8.3/branches/gc/src/comp_w8.c
r911 r1023 211 211 return; 212 212 } 213 words[i] = malloc(wordpos);213 words[i] = GC_MALLOC_ATOMIC(wordpos); 214 214 215 215 if (!words[i]) 1.8.3/branches/gc/src/conf.c
r945 r1023 39 39 #include "help.h" 40 40 #include "function.h" 41 #include "mymalloc.h" 41 42 #include "confmagic.h" 42 43 1.8.3/branches/gc/src/cque.c
r963 r1023 183 183 free_qentry(BQUE *point) 184 184 { 185 int a;186 for (a = 0; a < 10; a++)187 if (point->env[a]) {188 mush_free((Malloc_t) point->env[a], "bqueue_env");189 }190 for (a = 0; a < NUMQ; a++)191 if (point->rval[a]) {192 mush_free((Malloc_t) point->rval[a], "bqueue_rval");193 }194 if (point->semattr)195 mush_free((Malloc_t) point->semattr, "bqueue_semattr");196 if (point->comm)197 mush_free((Malloc_t) point->comm, "bqueue_comm");198 185 slab_free(bque_slab, point); 199 186 } … … 348 335 } 349 336 parse_que(executor, command, enactor); 350 free(start);351 337 return 1; 352 338 } 1.8.3/branches/gc/src/db.c
r935 r1023 150 150 while (db_top > db_size) 151 151 db_size *= 2; 152 if ((db = (struct object *)153 malloc(db_size * sizeof(struct object)))== NULL) {152 if ((db = GC_MALLOC_IGNORE_OFF_PAGE(db_size * sizeof(struct object))) 153 == NULL) { 154 154 do_rawlog(LT_ERR, "ERROR: out of memory while creating database!"); 155 155 abort(); … … 162 162 db_size *= 2; 163 163 if ((newdb = (struct object *) 164 realloc(db, db_size * sizeof(struct object))) == NULL) {164 GC_REALLOC(db, db_size * sizeof(struct object))) == NULL) { 165 165 do_rawlog(LT_ERR, "ERROR: out of memory while extending database!"); 166 166 abort(); … … 1152 1152 } 1153 1153 1154 free((char *) db);1155 1154 db = NULL; 1156 1155 db_init = db_top = 0; … … 1521 1520 fix_free_list(); 1522 1521 dbck(); 1523 log_mem_check();1524 1522 return db_top; 1525 1523 } … … 1548 1546 DBF_NEW_STRINGS | DBF_TYPE_GARBAGE | DBF_SPLIT_IMMORTAL | DBF_NO_TEMPLE | 1549 1547 DBF_SPIFFY_LOCKS; 1550 1551 log_mem_check();1552 1548 1553 1549 loading_db = 1; … … 1787 1783 fix_free_list(); 1788 1784 dbck(); 1789 log_mem_check();1790 1785 return db_top; 1791 1786 }
