diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:23:48 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:23:48 -0800 |
commit | 287d2535c79d1643338b466c3bbb5f729cb1e9bd (patch) | |
tree | b05e4e380191d60728239eb38c20c0ef9e077e9f /crawl-ref/source/random-weight.h | |
parent | 3be53369f544187af7bb88b1ee284ab1348f32af (diff) | |
download | crawl-ref-287d2535c79d1643338b466c3bbb5f729cb1e9bd.tar.gz crawl-ref-287d2535c79d1643338b466c3bbb5f729cb1e9bd.zip |
Was being passed choices via value, not reference
Since the vector random_choose_weighted() used was copied, the pointer
it returned became invalkid as soon as the function returned an the
copied vector went out of scope.
Diffstat (limited to 'crawl-ref/source/random-weight.h')
-rw-r--r-- | crawl-ref/source/random-weight.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crawl-ref/source/random-weight.h b/crawl-ref/source/random-weight.h index 2c7f8b9bca..8ef1291b69 100644 --- a/crawl-ref/source/random-weight.h +++ b/crawl-ref/source/random-weight.h @@ -8,7 +8,7 @@ * Returns NULL if nothing found, i.e., if all weights are zero. */ template <typename T> -T* random_choose_weighted(std::vector<std::pair<T, int> > choices) +T* random_choose_weighted(std::vector<std::pair<T, int> >& choices) { int total = 0; for (unsigned int i = 0; i < choices.size(); i++) |