Permalink
Browse files

kill some further mallocs and add note to remind us not to add them back

Conflicts:
	pdns/dnsparser.cc
  • Loading branch information...
1 parent 9df4944 commit dbedfc57e2556182d5a320d9b06b2bbf990bd8d3 @ahupowerdns ahupowerdns committed with Habbie Jan 6, 2015
Showing with 2 additions and 1 deletion.
  1. +2 −1 pdns/dnsparser.cc
View
@@ -437,6 +437,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
throw MOADNSException("Loop");
int pos = frompos;
+ // it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop
for(;;) {
unsigned char labellen=content.at(frompos++);
@@ -455,7 +456,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
}
else {
// XXX FIXME THIS MIGHT BE VERY SLOW!
- ret.reserve(ret.size() + labellen + 2);
+
for(string::size_type n = 0 ; n < labellen; ++n, frompos++) {
if(content.at(frompos)=='.' || content.at(frompos)=='\\') {
ret.append(1, '\\');

0 comments on commit dbedfc5

Please sign in to comment.