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: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] tds_get_string
  • Date: 30 Mar 2003 21:43:22 +0200

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.
Also for text field save a lot of memory (think a 2GB text..)

freddy77





Archive powered by MHonArc 2.6.24.

Top of Page