× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Mon, 10 May 2004, Bob Crothers wrote:

> Something is probably trashing your pointer.  Put a break point
> on the line after the malloc and then on the free.  Are the
> values the same?

You could also comment out the calls to QXXBTOZ and QXXZTOC just to prove
to yourself that those are what are messing up your pointer.  Couple of
other things as well:

> > /* Convert field to zoned. */
> > zlen = sizeof(decimal (DEC_DIG, 0) ) * 2  - 2;
> > znd = malloc(zlen);
> > result = QXXBTOZ(znd, zlen, bin, blen, hassign);
> >
> > if ( result ) return result;

You probably don't want to do the above since now you have a "memory
leak".  You return without freeing the allocated memory.  On the next
invocation of this function you allocate more memory again and possibly
return again without freeing it either.  Every time you return without
freeing the memory you lose the pointer to the memory and therefore can't
free it anymore.  Instead of the above "if ( result ) return result;" do
this:

if (result)
{
  free (znd);
  return (result);
}

> > result = QXXZTOC(chr, clen, znd, zlen, dp);
> >
> > /* Free allocated memory. */
> > free(znd);

Here you do free the malloc'ed memory, but I don't see the return
anywhere.  I assume it is there somewhere.  Just make sure the return
happens after you have freed the memory, or you will have the same problem
as I discussed above.

James Rich

Vs lbh guvax bs argjbex frphevgl nf na vzzhar flfgrz, Jvaqbjf vf UVI.
        -- Wbr Cyhgn

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.