freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Lowden, James K" <LowdenJK AT bernstein.com>
- To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] some small patches...
- Date: Tue, 15 Apr 2003 11:33:17 -0400
> From: Thompson, Bill D (London) [mailto:ThompBil AT exchange.uk.ml.com]
> Sent: April 15, 2003 10:55 AM
>
> No, free(NULL) does not cause me problems, I was just being careful.
That's good.
> > tds_free_context(TDSCONTEXT *context)
> > {
> > tds_free_locale(context->locale);
> > TDS_ZERO_FREE(context);
> > }
>
> Well no... if context is NULL, you'll segment on referencing
> context->locale, so you need at least to check whether
> context is NULL or not...
Oops!
> so I guess you could simplify to....
>
> void tds_free_context(TDSCONTEXT *context)
> {
> if (context) {
> tds_free_locale(context->locale);
> context->locale = NULL;
> TDS_ZERO_FREE(context);
> }
> }
That's effectively what's in CVS now.
> if (g_dblib_ctx.tds_ctx) {
> tds_free_context(g_dblib_ctx.tds_ctx);
> g_dblib_ctx.tds_ctx = NULL;
> }
>
> Although tds_free_context freed the storage pointed to by *context ,
> g_dblib_ctx.tds_ctx was still set, as the pointer had been
> passed by value, not reference...
Come to think of it,
> context->locale = NULL;
> TDS_ZERO_FREE(context);
is two degrees of silliness. Not only is there no effect of
"context->locale = NULL", there's no effect the implicit "context = NULL"
either. Whoever calls tds_free_context() won't see any changed value of
context, because, as you say, it's passed by value.
We probably should avoid TDS_ZERO_FREE() in situations like this because
it's deceptive, and just use free() instead.
Thanks for the patches, Bill. Are you going to switch over to the newly
disturbed HEAD soon? I know you're planning a lot of work on ct-lib, and I
wouldn't want us to get too far out of synch.
--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.
-
[freetds] some small patches...,
Thompson, Bill D (London), 04/15/2003
- <Possible follow-up(s)>
- RE: [freetds] some small patches..., Lowden, James K, 04/15/2003
- RE: [freetds] some small patches..., Thompson, Bill D (London), 04/15/2003
- RE: [freetds] some small patches..., Lowden, James K, 04/15/2003
- RE: [freetds] some small patches..., Lowden, James K, 04/15/2003
- RE: [freetds] some small patches..., Thompson, Bill D (London), 04/15/2003
Archive powered by MHonArc 2.6.24.