Skip to Content.
Sympa Menu

freetds - RE: [freetds] tdsstring.c ansi alias problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] tdsstring.c ansi alias problem
  • Date: Mon, 5 May 2003 11:34:36 -0400

> From: Craig A. Berry [mailto:craigberry AT mac.com]
> Sent: May 4, 2003 11:26 PM
>
> D0:[CRAIG.FREETDS-0_62_DEV_20030503.SRC.TDS]TDSSTRING.C;1,
> which uses the type "pointer to struct DSTR_CHAR".
...
>
> DSTR
> tds_dstr_set(DSTR * s, char *src)
> {
> if (*(char **) s != tds_str_empty)
> free(*(char **) s);
> *(char **) s = src;
> return *s;
> }
>
>
> I guess I don't understand the purpose of casting the
> left-hand side of "*(char **) s = src;"

Where is DSTR_CHAR defined? I find only a forward declaration in tds.h.
I've looked in unixodbc and on my Win32 box:

$ grep DSTR_CHAR include/* src/*/*.c win32/*
include/tds.h:struct DSTR_CHAR;
include/tds.h:typedef struct DSTR_CHAR *DSTR;

I can't even explain how the above compiles. That doesn't prevent me from
thinking it's ugly, and afaik "free(*(char **) s);" is identical to
"free(s);" in all cases, as far as the compiler and free store are
concerned.

There must be a better way to do this than casting the living daylights out
of it....

--jkl


The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. Please note that we do not accept account orders and/or
instructions by e-mail, and therefore will not be responsible for carrying
out such orders and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page