Здравствуйте Ronald,

Monday, June 30, 2003, 5:45:26 PM, Вы писали:

RJK> On Mon, Jun 30, 2003 at 09:47:25AM +0400, Монашёв Михаил wrote:

>>         return "$lp$str$ls";  # <-- memory leak is here, return $lp.$str.ls; better

RJK> String interpolation is already compiled into concatenation operations:

RJK> % perl -MO=Deparse,-q -e '$x = "$lp$str$ls"; $x = $lp.$str.$ls;'
RJK> $x = $lp . $str . $ls;
RJK> $x = $lp . $str . $ls;
RJK> -e syntax OK

RJK> (There is a slight difference in the resulting op-codes.)

RJK> Have you tested your change to see if it fixes the memory leak?


RJK> Ronald

   sorry.
   I test script with changes in DBI.pm :

    sub quote {
        my ($dbh, $str, $data_type) = @_;

        return "NULL" unless defined $str;
        unless ($data_type) {
            $str =~ s/'/''/g;           # ISO SQL2
            #return "'$str'";
                return "'".$str."'";
        }

        my $dbi_literal_quote_cache = $dbh->{'dbi_literal_quote_cache'} ||= [ {} , {} 
];
        my ($prefixes, $suffixes) = @$dbi_literal_quote_cache;

        my $lp = $prefixes->{$data_type};
        my $ls = $suffixes->{$data_type};

        if ( ! defined $lp || ! defined $ls ) {
            my $ti = $dbh->type_info($data_type);
            $lp = $prefixes->{$data_type} = $ti ? $ti->{LITERAL_PREFIX} || "" : "'";
            $ls = $suffixes->{$data_type} = $ti ? $ti->{LITERAL_SUFFIX} || "" : "'";
        }
        return $str unless $lp || $ls; # no quoting required

        # XXX don't know what the standard says about escaping
        # in the 'general case' (where $lp != "'").
        # So we just do this and hope:
        $str =~ s/$lp/$lp$lp/g
                if $lp && $lp eq $ls && ($lp eq "'" || $lp eq '"');
        #return "$lp$str$ls";
        return $lp.$str.$ls;
    }

    but i still have memort leak :(
    where is it? can you show me bad code in DBI.pm
    quote() is very usefull function? but it make big memory leak.
    maybe somebody have similar function like quote() ?
  

С уважением,
Монашёв Михаил, SoftSearch.ru
mailto:[EMAIL PROTECTED]
ICQ# 166233339
http://softsearch.ru/
Без бэкапа по жизни.

  • ... Монашёв Михаил
    • ... Монашёв Михаил
      • ... gregg
        • ... Монашёв Михаил
          • ... Ronald J Kimball
            • ... Монашёв Михаил
              • ... Rudy Lippan
                • ... Монашёв Михаил
                • ... Paul Boutros
                • ... Монашёв Михаил
                • ... Rudy Lippan
                • ... Монашёв Михаил
                • ... Rudy Lippan
                • ... David N Murray
                • ... Rudy Lippan
      • ... Rudy Lippan

Reply via email to