[freetds] tdsstring.c ansi alias problem

Lowden, James K LowdenJK at bernstein.com
Mon May 5 11:34:36 EDT 2003

> From: Craig A. Berry [mailto:craigberry at mac.com]
> Sent: May 4, 2003 11:26 PM
> which uses the type "pointer to struct DSTR_CHAR".  
> 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

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


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.

More information about the FreeTDS mailing list