Skip to Content.
Sympa Menu

freetds - Re: [freetds] tds_get_string

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] tds_get_string
  • Date: Mon, 31 Mar 2003 06:39:20 -0500

On 30 Mar 2003 21:43:22 +0200, Frediano Ziglio <freddyz77 AT tin.it> wrote:
> Il dom, 2003-03-30 alle 21:32, James K. Lowden ha scritto:
> > read.c::tds_get_string() contains what looks like a silly loop:
> >
> > char temp[256];
> > char *p, *pend;
> > /* ... */
> > while (string_len > 0 && p < pend) {
> > in_left = string_len > (sizeof(temp) / 2) ?
> > (sizeof(temp) / 2) : string_len;
> > tds_get_n(tds, temp, in_left * 2);
> > p += tds7_unicode2ascii(tds, temp, in_left, p, pend - p);
> > string_len -= in_left;
> > }
> > return p - dest;
> >
> > Basically, if the input string is more than 128 characters, we call
> > tds_get_n() and tds7_unicode2ascii() in 128-character chunks.
> >
> > Why do we do this? I can't see any reason.
>
> Cause you don't use malloc?
> tds_get_string can't return a "I'm sorry but your computer is out of
> memory" results, so avoiding malloc fix the problem.

Thanks, I see. I think I misread the logic. temp is the
"preconversion" buffer, the place where the UCS-2 data are parked
before converting them to ASCII. It has to have a size, and there's
no advantage to allocating dynamically.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page