Re: Patch proposal

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <1308328419.5884.7.camel@ricky>
Il giorno gio, 16/06/2011 alle 10.45 -0400, [email protected] ha
scritto:
> On Thu, Jun 16, 2011 at 09:32:52AM +0200, Frediano Ziglio wrote:
> >   I would like to include this patch (and follows). It define some
> > macro to merge allocation and casting.
> 
> Hi Freddy, 
> 
> Why do you want to do this?  
> 

I think Christos replied to this. I was trying to compile FreeTDS with C
++ so to remove warnings I added destination casts however I remember
that I added (years ago) casts in mem.c so I though that even some C
compiler complain but now I think I probably used a gcc option to add
this warning, like a type safe warning or something like that. 

> Any use of the preprocessor makes the code more obscure.  As someone who
> knows the code, it's hard enough to understand/remember macro definitions.
> Someone new who'd like to contribute will have a harder time every time he
> encounters a macro.  
> 
> > see this patch as an example
> > 
> > 
> > diff --git a/src/ctlib/ct.c b/src/ctlib/ct.c
> > index e7217a9..9e2f03e 100644
> > --- a/src/ctlib/ct.c
> > +++ b/src/ctlib/ct.c
> > @@ -279,7 +279,7 @@ ct_con_alloc(CS_CONTEXT * ctx, CS_CONNECTION ** con)
> >         login = tds_alloc_login();
> >         if (!login)
> >                 return CS_FAIL;
> > -       *con = (CS_CONNECTION *) calloc(1, sizeof(CS_CONNECTION));
> > +       *con = tds_zalloc(CS_CONNECTION);
> ...
> > as you can see line is shorter. Do you think tds_allocz is better than
> > tds_zalloc?
> 
> But here's short enough, and right, and clear:
> 
>   +       *con = calloc(1, sizeof(CS_CONNECTION));
>   
> What's wrong with that?  
> 
> I've been writing C code since 1985 and I know how to allocate and free memory
> using the C standard library.  I prefer to write and read C code that K&R would
> recognize (if not necessarily approve of).  
> 

Oh my god! K&R ?? I think that our project is no more K&R since...
ever... When I studied C for the first time K&R was just a funny think
to show how C changed :)

Don't mind, was just an idea like many others.

> Regards, 
> 
> --jkl

bye
  Frediano
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.