Eggheads: Aaaargh

Paul PaulE at Blueyonder.co.uk
Sat Aug 16 15:48:22 CST 2003


>From the looks of things though, it is possible to tell a 'builtin' bind
from a tcl bind, thus it would be possible to create two codepaths, thus
adding a little bit more speed.

I guessing this would break the tcl-C bridge mind, which not really
being a tcl programmer I suppose isnt my first priority.... Mind you, if
it aint broke, then why fix it... You need any more programmers at the
moment? Lol

While I have your attention :) ... One more question.... (columbo
stylee)

As I'm always developing modules, I use a lot of .loadmod / .unloadmod
whilst I'm recompiling it. For simplicity, I store some custom
user-specific data within the XTRA key within the user entry. For this I
use user_malloc along these lines...

static void SetXtra(char * pHand, char * pField, char * pData)
{
	struct userrec			* pUser;
	struct xtra_key			* pXtraKey;

	Context;

	pUser = get_user_by_handle(userlist, pHand);

	if(pUser)
	{
		Context;

		pXtraKey = user_malloc(sizeof(struct xtra_key));

		pXtraKey->key = user_malloc(strlen(pField) + 1);
		pXtraKey->data = user_malloc(strlen(pData) + 1);

		strcpy(pXtraKey->key, pField);
		strcpy(pXtraKey->data, pData);
		pXtraKey->next = NULL;

		set_user(&USERENTRY_XTRA, pUser, pXtraKey);
	}
}

However, I find if you unload the mod I start getting memory leaks in
the main bot, and inevitable crashes. Presumably this has something to
do with the main bot thinking the memory is still allocated when it has
in fact been freed... But then that's what I thought user_malloc was
for...

Am I going about this the wrong way, or is this just something I'm gonna
have to live with?

P.

-----Original Message-----
From: eggheads-bounces at eggheads.org
[mailto:eggheads-bounces at eggheads.org] On Behalf Of stdarg
Sent: 16 August 2003 18:20
To: Eggdrop Discussion List
Subject: RE: Eggheads: Aaaargh



--- Paul <PaulE at Blueyonder.co.uk> wrote:
> Thanks for your quick reply - I'll apply that patch for now, but just 
> to check, is the correct order of arguments
> 
> static int QAUTH_HandleNotices(char * pNick, char * pHost, char * 
> pHand, char * pText, char * pDest) ??

Yeah that looks right, it should be just like for tcl procs.

> 
> I was trying to track down the bug in order to confirm it, but I got a

> little confused as to how/where server_5char / server_6char gets 
> called
> - does this come from the Tcl_VarEval call in Trigger_Bind() (which I
> find dubious) or do builtins get intercepted at a higher level I hadnt
> noticed yet?

The confusing bit about the whole process is that, sadly, all binds get
converted into tcl commands and get executed via the tcl interpreter,
even when they start out as C functions. When you add a bind to H_notc,
for instance, eggdrop creates a stub tcl command using server_5char. It
saves your function so that it can call it later. Server_5char then
converts the tcl arguments from the bind into C arguments and calls your
function.

So yes, server_5char is called by trigger_bind() via the tcl
interpreter.

> 
> P.
> 

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



More information about the Eggheads mailing list