freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: jklowden AT schemamania.org
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Patch proposal
- Date: Thu, 16 Jun 2011 10:45:24 -0400
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?
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).
Regards,
--jkl
-
[freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
-
Re: [freetds] Patch proposal,
Christos Zoulas, 06/16/2011
-
Re: [freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
- Re: [freetds] Patch proposal, Christos Zoulas, 06/16/2011
-
Re: [freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
-
Re: [freetds] Patch proposal,
jklowden, 06/16/2011
- Re: [freetds] Patch proposal, Frediano Ziglio, 06/17/2011
-
Re: [freetds] Patch proposal,
Christos Zoulas, 06/16/2011
Archive powered by MHonArc 2.6.24.