Skip to Content.
Sympa Menu

freetds - Re: [freetds] _DB_GETCOLINFO whacked

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] _DB_GETCOLINFO whacked
  • Date: Mon, 3 Dec 2007 11:02:41 +0100

>
> I removed the _DB_GETCOLINFO macro, replacing it with a function
> dbcolptr(). The macro had gotten too complicated and wasn't
> all that well
> conceived to begin with.
>
> In general I think it's a bad idea for macros to have side
> effects. This
> one required two variables to be declared, so it could assign
> them, and
> contained return statements in case its checks turned up an error. I
> didn't think "get column info" suggested "exit if you can't".
>
> The new function calls dbperror() for you and returns the
> error code, so
> the caller can decide what to do next. It takes the address of a
> TDSCOLUMN pointer, which is sets. I think it makes what's going on a
> little clearer.
>


Yes, was quite complicated... however I would prefer if dbcolptr returns
TDSCOLUM* directly... of course cause it's better optimized!! Passing a
pointer to pointer means that compiler have to allocate space in memory
to pass the buffer while returning directly a pointer compiler can (and
probably do) return a register. Also you can use a macro that don't have
side effects like

#define _DB_GETCOLINFO(fail) \
do { if ((colinfo = dbcolptr(dbproc, column)) == NULL) return
(fail); } while(0)

(or just inline it on every call...)

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page