BIND 10 trac2272, updated. 3148cf2b018b222e263894b80cd7e92b20c86ceb [2272] Replaced malloc with new in command options helper.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 20 11:25:48 UTC 2012
The branch, trac2272 has been updated
via 3148cf2b018b222e263894b80cd7e92b20c86ceb (commit)
from d26707201f5c67cae4b3439ef63809da41e8d166 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3148cf2b018b222e263894b80cd7e92b20c86ceb
Author: Marcin Siodelski <marcin at isc.org>
Date: Thu Sep 20 13:25:35 2012 +0200
[2272] Replaced malloc with new in command options helper.
-----------------------------------------------------------------------
Summary of changes:
.../tools/perfdhcp/tests/command_options_helper.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/tests/tools/perfdhcp/tests/command_options_helper.h b/tests/tools/perfdhcp/tests/command_options_helper.h
index 860a040..d1d1fb4 100644
--- a/tests/tools/perfdhcp/tests/command_options_helper.h
+++ b/tests/tools/perfdhcp/tests/command_options_helper.h
@@ -57,10 +57,10 @@ public:
~ArgvPtr() {
if (argv_ != NULL) {
for(int i = 0; i < argc_; ++i) {
- free(argv_[i]);
+ delete[] (argv_[i]);
argv_[i] = NULL;
}
- free(argv_);
+ delete[] (argv_);
}
}
@@ -115,14 +115,15 @@ private:
if (tokens.size() > 0) {
// Allocate array of C-strings where we will store tokens
- results = static_cast<char**>(malloc(tokens.size() * sizeof(char*)));
- if (results == NULL) {
- isc_throw(Unexpected, "unable to allocate array of c-strings");
- }
+ results = new (std::nothrow) char*[tokens.size() * sizeof(char*)];
+ assert(results != NULL);
// Store tokens in C-strings array
for (int i = 0; i < tokens.size(); ++i) {
- char* cs = static_cast<char*>(malloc(tokens[i].length() + 1));
- strcpy(cs, tokens[i].c_str());
+ size_t cs_size = tokens[i].length() + 1;
+ char* cs = new (std::nothrow) char[cs_size];
+ assert (cs != NULL);
+ strncpy(cs, tokens[i].c_str(), cs_size);
+ assert(cs[cs_size - 1] == '\0');
results[i] = cs;
}
// Return number of tokens to calling function
More information about the bind10-changes
mailing list