Re: [code][verification...]

From: Sammy (Samedi@cris.com)
Date: 12/16/96


On Sat, 14 Dec 1996, invincibill wrote:

- i have been having problems with obuild's zload and zequip.  i THINK the
- problem is with the way it adds new objects and mobs and such to the
- zone table...
- 
- since the world tables use an array(of sorts..) every time i add, say a
- new command to a particular command table, i need to allocate enough
- memory for a whole new zone table?  or just that command table?  copy it
- over, adding the new command and then free the old table(in a nut
- shell)  

When you add a zone, it reallocates the zone table, but when you add a
reset command, it only reallocates the command table for that zone.  THe
rest is correct.

- is this right? i have been working on this problem for a week and i cant
- seem to find why the mud crashes.  it doesnt crash right away.  so i'm
- assuming its a problem with some memory getting overwritten.  only thing
- is, all the code looks fine.  what it does currently is just allocate
- enough memory for the old command table, plus the new command table then
- copies the old to a new one, adding in the command.  doesnt this
- overwrite memory that something else is using?  i think it does...and
- i'm gonna go on that assumption,  just wanting to get some verification
- on this.  am i afu??

It shouldn't be overwriting any memory.  The way it's designed, it counts
the number of commands in the current command table, then allocates memory
for that many command plus the new one.  This is new memory that is
requested from the operating system and so isn't used by any other part of
circle.  Then it frees thememory from the old reset table so it can be
recycled.  The comman problem with arrays is that if you've allocated
memory for 5 elements and try to write a 6th element, you're writing over
something that wasn't allocated for your array.  If it belongs to
something other than circle you get a segfault.  If it belongs to circle,
it'll probably just overwrite something important and crash later.

Sorry I can't offer any helpful advice, but maybe this info will help you
to debug it.

Sam

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST