Skip to Content.
Sympa Menu

freetds - RE: Reusing CS_COMMAND structures

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Sam Denton <denton AT wantec.com>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Reusing CS_COMMAND structures
  • Date: Thu, 23 May 2002 12:58:40 -0500


Patient: "Doctor, it hurts when I do *this*."
Doctor: "Well, then, don't do that any more."

;-) Sorry, I couldn't resist.

But seriously, I can't see anything obviously wrong with the code. How does
the crash manifest itself? Could something be overwriting your CS_COMMAND
structure? The relevant bits of code from ct.c look like this:

In ct_cmd_alloc:
*cmd = (CS_COMMAND *) malloc(sizeof(CS_COMMAND));
memset(*cmd,'\0',sizeof(CS_COMMAND));
In ct_command:
if (cmd->query) free(cmd->query);
cmd->query = (char *) malloc(query_len + 1);
In ct_cmd_drop:
if (cmd) {
if (cmd->query) free(cmd->query);
free(cmd);
}
In ct_dynamic:
if (cmd->query) free(cmd->query);
cmd->query = (char *) malloc(query_len + 1);

I'd insert some printf's before and after these locations and see what
cmd->query contains.

BTW, there's what looks like a memory leak in ct_cmd_drop. Right now, it's
only freeing cmd->query, but there's also a cmd->dyn_id that can be
allocated. I can't find anyplace where it's getting freed. OTOH, I don't
have the latest version of the source.

Sam Denton, WAN Technologies, INC.
(314) 428-0888 / (800) 926-7771 Main Office


-----Original Message-----
From: David Nahman [mailto:vanyadog AT yahoo.com]
Sent: Wednesday, May 22, 2002 8:44 PM
To: TDS Development Group
Subject: [freetds] Reusing CS_COMMAND structures


Dear list,

Is it okay to re-use CS_COMMAND structures: i.e.
allocate them once, and then re-use them after
ct_results returns something other than CS_SUCCEED?

I ask because I am crashing when I reuse a CS_COMMAND
structure after a query failes. The program crashes
at line 340 in ct.c on:
if (cmd->query) free(cmd->query);


Should I be alloc'ing and dropping the structure in
between each query?

Thanks,
David Nahman


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

---
You are currently subscribed to freetds as: [denton AT wantec.com]
To unsubscribe, forward this message to
$subst('Email.Unsub')




Archive powered by MHonArc 2.6.24.

Top of Page