Some time ago someone reported a bug in stock CircleMUD bpl 12 with loading of help files. The problem is memory overrun if you have more than 2 aliases per help entry in average, which results in a crash. I recently bumped into this bug and fixed it this way: Previously Circle counted number of "#" in a help file and allocated space for (number of "#") * 2 aliases. I changed it slightly and now it will count number of aliases in help file and allocate as much space, as needed. So - no more possible memory overruns and crashes and all allocated memory is used. I tested this code with my help files and it seems to work ok. Here is the code: ----------------------------------------------------------------------------- In DB.C Before index_boot function, insert this function: ----------------------------------------------------------------------------- /* function to count how many aliases exist in a help file */ int count_alias_records(FILE *fl) { char key[READ_SIZE+1], next_key[READ_SIZE+1]; char line[READ_SIZE+1], *scan; int total_keywords = 0; /* get the first keyword line */ get_one_line(fl, key); while (*key != '$') { /* skip the text */ get_one_line(fl, line); while (*line != '#') get_one_line(fl, line); /* now count keywords */ scan = one_word(key, next_key); ++total_keywords; while (*next_key) { scan = one_word(scan, next_key); ++total_keywords; } /* get next keyword line (or $) */ get_one_line(fl, key); } return total_keywords; } ----------------------------------------------------------------------------- Btw, since function above uses get_one_line() before it was declared, you should prototype it at the beginning of db.c. Around line 508, look for: ----------------------------------------------------------------------------- if (mode == DB_BOOT_ZON) rec_count++; else rec_count += count_hash_records(db_file); } ----------------------------------------------------------------------------- and change it to: ----------------------------------------------------------------------------- if (mode == DB_BOOT_ZON) rec_count++; else if (mode == DB_BOOT_HLP) rec_count += count_alias_records(db_file); else rec_count += count_hash_records(db_file); } ----------------------------------------------------------------------------- Arount line 540 look for: ----------------------------------------------------------------------------- case DB_BOOT_HLP: CREATE(help_table, struct help_index_element, rec_count * 2); break; ----------------------------------------------------------------------------- and change it to: ----------------------------------------------------------------------------- case DB_BOOT_HLP: CREATE(help_table, struct help_index_element, rec_count); break; ----------------------------------------------------------------------------- Now everything should work fine. Andrey (andrey@alex-ua.com) aka Zmey//RMUD +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST