I am sorry, I haven't seem to have given enough information, and I had deleted a few things to (hopefully) clarify the problem I was having (as I didn't want to get bogged down in details which didn't seem to matter, as I will explain below).

First, acct_flags is basically an unlimited bit system based upon a array (string) of characters. Index actually involves some tricks getting the right bit from the right character; since all of the tests I performed indicated the mud was not crashing there, I simplified it to a simple reference (which is what it basically is).

The point is that acct_flags is a pointer, and may or may not be pointing to anything of note. The mud is crashing whenever I try to logon, so acct_flags should be set to NULL. In the line I indicated, "if( acct_flags )", I am checking to see if the pointer is safe to dereference. If it's is, I pull the value for the bit at index, and return that, otherwise I return FALSE. I would understand a segmentation fault if I tried to dereference a NULL pointer, or a junk pointer, but the function is crashing when I try to check the contents of the pointer itself (ie, not what it's pointing at)! I've used code like this in many places; ROM uses code like this in many places; I don't understand why it doesn't work here.

I was just wondering if anyone else had seen anything like this before, or knew of some other stupid thing I might have done that would manifest itself in this way.

T.H.C

At 08:03 AM 7/13/2002 -0500, Tom Whiting wrote:
hmmmm,
well, I see your point there honestly, BUT, if you want it to return
something ele (ie: what the flag actually is), then yo're pretty much
going to have to rewrite it. As I don't see but maybe 5 lines of code, I
must borrow Edwin's crystal ball sometimes, and lately that's been
lettin me down.. :P

As I said though, the line you're choking on is PROBABLY because
acct_flags isn't initialized (unless that's done globally).
You can't just throw arguments into a statement like this. Where are
acct_flags coming from? They're used 2x, one looks like it's a field,
one a structure, so that could be a problem too.
Start, with trying to clean up the way acct_flags are handled in this
bit of code..
Sorry I can't be much more help

On Sat, 2002-07-13 at 07:54, Jason Gauthier wrote:
> Actually, a bool is TRUE if the comparison in question does not evaluate to
> 0.
>
> So, what you state is correct, it's for TRUE or FALSE.
> What he is using it for here, is legitimate.
>

> > Can anyone help me with a very strange problem I am having? Basically, my
> > code looks like:
> >
> > bool get_flag( int index )
> > {
> >          bool ret_val = FALSE;
> >          if( acct_flags )                                       ***
> >                  ret_val = acct_flags->bit[ index ];
> >
> >          return ret_val;
> > }
> First off, bool is for boolean functions, and SHOULD only return TRUE or
> FALSE, nothing else.
> so, that said, you might consider redoing somthing like int get_flag(int
> index), instead.. That seems to be more appropriate.
>

--
TJW      :Head tech, designer, bum:P
Mud      :http://dreamless.wolfstream.net
telnet   :telnet://dreamless.wolfstream.net 9275
OLC Pages:http://olc.wolfstream.net



--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom


Reply via email to