Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Langford <jl@nyclamp.(none)>2014-03-31 19:51:01 +0400
committerJohn Langford <jl@nyclamp.(none)>2014-03-31 19:51:01 +0400
commitce8ffc8ff5821cc45f28739bc0889dc697dc8f98 (patch)
treefb0ef43ec0e37097dd156ae9b24d5295bb97b438 /vowpalwabbit/parse_args.cc
parent5023ab65297cc03427afc8ca3d2c7730383b633f (diff)
error check all calls to calloc
Diffstat (limited to 'vowpalwabbit/parse_args.cc')
-rw-r--r--vowpalwabbit/parse_args.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/vowpalwabbit/parse_args.cc b/vowpalwabbit/parse_args.cc
index 26ad3b24..15856d72 100644
--- a/vowpalwabbit/parse_args.cc
+++ b/vowpalwabbit/parse_args.cc
@@ -40,6 +40,7 @@ license as described in the file LICENSE.
#include "binary.h"
#include "lrq.h"
#include "autolink.h"
+#include "memory.h"
using namespace std;
//
@@ -64,7 +65,7 @@ bool valid_ns(char c)
void parse_affix_argument(vw&all, string str) {
if (str.length() == 0) return;
- char* cstr = (char*)calloc(str.length()+1, sizeof(char));
+ char* cstr = (char*)calloc_or_die(str.length()+1, sizeof(char));
strcpy(cstr, str.c_str());
char*p = strtok(cstr, ",");
@@ -983,7 +984,7 @@ vw* parse_args(int argc, char *argv[])
all->cost_sensitive = all->l;
got_cs = true;
}
- //all->searnstr = (Searn::searn*)calloc(1, sizeof(Searn::searn));
+ //all->searnstr = (Searn::searn*)calloc_or_die(1, sizeof(Searn::searn));
all->l = Searn::setup(*all, to_pass_further, vm, vm_file);
}
@@ -1071,7 +1072,7 @@ namespace VW {
char** get_argv_from_string(string s, int& argc)
{
- char* c = (char*)calloc(s.length()+3, sizeof(char));
+ char* c = (char*)calloc_or_die(s.length()+3, sizeof(char));
c[0] = 'b';
c[1] = ' ';
strcpy(c+2, s.c_str());
@@ -1080,11 +1081,11 @@ namespace VW {
foo.end_array = foo.begin = foo.end = NULL;
tokenize(' ', ss, foo);
- char** argv = (char**)calloc(foo.size(), sizeof(char*));
+ char** argv = (char**)calloc_or_die(foo.size(), sizeof(char*));
for (size_t i = 0; i < foo.size(); i++)
{
*(foo[i].end) = '\0';
- argv[i] = (char*)calloc(foo[i].end-foo[i].begin+1, sizeof(char));
+ argv[i] = (char*)calloc_or_die(foo[i].end-foo[i].begin+1, sizeof(char));
sprintf(argv[i],"%s",foo[i].begin);
}