Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JohnLangford/vowpal_wabbit
Browse files Browse the repository at this point in the history
…into skype
  • Loading branch information
eisber committed Apr 19, 2018
2 parents 90cd2d0 + abd3561 commit 76d7927
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions vowpalwabbit/parse_args.cc
Expand Up @@ -183,7 +183,8 @@ void parse_dictionary_argument(vw&all, string str)
THROW("error: cannot re-read dictionary from file '" << fname << "'" << ", opening failed");
}

feature_dict* map = new feature_dict(1023, nullptr, substring_equal);
feature_dict* map = &calloc_or_throw<feature_dict>();
map->init(1023, nullptr, substring_equal);
example *ec = VW::alloc_examples(all.p->lp.label_size, 1);

size_t def = (size_t)' ';
Expand Down Expand Up @@ -941,7 +942,8 @@ void parse_example_tweaks(arguments& arg)

if (arg.vm.count("named_labels"))
{
arg.all->sd->ldict = new namedlabels(named_labels);
arg.all->sd->ldict = &calloc_or_throw<namedlabels>();
new (arg.all->sd->ldict) namedlabels(named_labels);
if (!arg.all->quiet)
arg.trace_message << "parsed " << arg.all->sd->ldict->getK() << " named labels" << endl;
}
Expand Down Expand Up @@ -1584,7 +1586,11 @@ void finish(vw& all, bool delete_all)
seeded = false;
if (!seeded)
{
delete(all.sd->ldict);
if (all.sd->ldict)
{
all.sd->ldict->~namedlabels();
free(all.sd->ldict);
}
free(all.sd);
}
all.reduction_stack.delete_v();
Expand All @@ -1606,7 +1612,7 @@ void finish(vw& all, bool delete_all)

all.loaded_dictionaries[i].dict->iter(delete_dictionary_entry);
all.loaded_dictionaries[i].dict->delete_v();
delete all.loaded_dictionaries[i].dict;
free(all.loaded_dictionaries[i].dict);
}
delete all.loss;

Expand Down
6 changes: 3 additions & 3 deletions vowpalwabbit/v_hashmap.h
Expand Up @@ -38,7 +38,7 @@ template<class K, class V> class v_hashmap
void set_default_value(V def) { default_value = def; }

void init_dat(size_t min_size, V def, bool (*eq)(void*,K&,K&), void *eq_dat = nullptr)
{ dat = v_init<hash_elem>();
{
if (min_size < 1023) min_size = 1023;
dat.resize(min_size, true); // resize sets to 0 ==> occupied=false

Expand All @@ -52,7 +52,7 @@ template<class K, class V> class v_hashmap
}

void init(size_t min_size, V def, bool (*eq)(K&,K&))
{ dat = v_array<hash_elem>();
{
if (min_size < 1023) min_size = 1023;
dat.resize(min_size); // resize sets to 0 ==> occupied=false

Expand All @@ -66,7 +66,7 @@ template<class K, class V> class v_hashmap
}

void init(size_t min_size, bool (*eq)(K&,K&))
{ dat = v_array<hash_elem>();
{
if (min_size < 1023) min_size = 1023;
dat.resize(min_size); // resize sets to 0 ==> occupied=false

Expand Down

0 comments on commit 76d7927

Please sign in to comment.