diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-12-14 12:07:24 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-12-14 12:07:24 +0100 |
commit | dc4002d8c3c687e6614d01b34e4b6aa929411ea9 (patch) | |
tree | 8a842af457cfb159741b6c84ee7ab6fc094b88e7 /apt-pkg/deb/debsrcrecords.cc | |
parent | 7570b65d5eae54c51689121a317351a1cd42e64d (diff) | |
parent | 19ec5723caa6ea6ab196a9e960c769ded4ee0d28 (diff) |
* merged with apt--mvo
Diffstat (limited to 'apt-pkg/deb/debsrcrecords.cc')
-rw-r--r-- | apt-pkg/deb/debsrcrecords.cc | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index cac36c2e6..7d5dab747 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -18,6 +18,8 @@ #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> #include <apt-pkg/configuration.h> + +using std::max; /*}}}*/ // SrcRecordParser::Binaries - Return the binaries field /*{{{*/ @@ -34,31 +36,19 @@ const char **debSrcRecordParser::Binaries() if (Bins.empty() == true || Bins.length() >= 102400) return 0; - // Workaround for #236688. Only allocate a new buffer if the field - // is large, to avoid a performance penalty - char *BigBuf = NULL; - char *Buf; - if (Bins.length() > sizeof(Buffer)) - { - BigBuf = new char[Bins.length()]; - Buf = BigBuf; - } - else + if (Bins.length() >= BufSize) { - Buf = Buffer; + delete [] Buffer; + // allocate new size based on buffer (but never smaller than 4000) + BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize)); + Buffer = new char[BufSize]; } - strcpy(Buf,Bins.c_str()); - if (TokSplitString(',',Buf,StaticBinList, + strcpy(Buffer,Bins.c_str()); + if (TokSplitString(',',Buffer,StaticBinList, sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false) - { - if (BigBuf != NULL) - delete BigBuf; return 0; - } - if (BigBuf != NULL) - delete BigBuf; return (const char **)StaticBinList; } /*}}}*/ |