Re: Finding Type of a Void Pointer

From: Chris Jacobson (fear@ATHENET.NET)
Date: 11/29/97


On 11/29/97 2:11 AM, ;P (siv@CYBERENET.NET) stated:

>but i can't think of how to determine whether its an object or char..uh..
>any ideas?

* WARNING: MAILER CODE *


Put a single-byte "type" field in your event struct.

Then whenever you ADD_EVENT, just add the variable "type" to the
function...

#define OBJ_CAUSER  (1 << 0)
#define CHAR_CAUSER (1 << 1)
#define MISC_CAUSER (1 << 2)
#define OBJ_VICTIM  (1 << 4)
#define CHAR_VICTIM (1 << 5)
#define MISC_VICTIM (1 << 6)

And if you want:

#define FREE_INFO   (1 << 7)

This will allow you to also define the victim...
Like:

#define EVENT_TYPE(event, kind)  (event->type & kind)

Plus the advantage with the FREE_INFO flag is that if when you cancel an
event, you can check for the flag, and if it is there, free the info
field.  This also has the advantage of letting you use the info field for
something other than a pointer or a custom structure, which is stuff I
do.  No more memory leak with that then.

- Chris Jacobson


     +------------------------------------------------------------+
     | 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