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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2013-01-18 19:58:54 +0400
committerKenneth Heafield <github@kheafield.com>2013-01-18 19:59:51 +0400
commitfc5868d0fff647c3879668af4bfe6e1bab9e83ab (patch)
treed9b5026f32cc5ae603e6f42b1fc7128aeee4ba55 /util/scoped.hh
parent5f7b91e702f809577d82a7570778d254d985ba93 (diff)
KenLM df5be22 lmplz for estimation
Diffstat (limited to 'util/scoped.hh')
-rw-r--r--util/scoped.hh17
1 files changed, 10 insertions, 7 deletions
diff --git a/util/scoped.hh b/util/scoped.hh
index 37bc4744f..d0a5aabd0 100644
--- a/util/scoped.hh
+++ b/util/scoped.hh
@@ -4,28 +4,31 @@
#include "util/exception.hh"
#include <cstddef>
-#include <cstdlib>
namespace util {
+class MallocException : public ErrnoException {
+ public:
+ explicit MallocException(std::size_t requested) throw();
+ ~MallocException() throw();
+};
+
+void *MallocOrThrow(std::size_t requested);
+
class scoped_malloc {
public:
scoped_malloc() : p_(NULL) {}
scoped_malloc(void *p) : p_(p) {}
- ~scoped_malloc() { std::free(p_); }
+ ~scoped_malloc();
void reset(void *p = NULL) {
scoped_malloc other(p_);
p_ = p;
}
- void call_realloc(std::size_t to) {
- void *ret;
- UTIL_THROW_IF(!(ret = std::realloc(p_, to)) && to, ErrnoException, "realloc to " << to << " bytes failed.");
- p_ = ret;
- }
+ void call_realloc(std::size_t to);
void *get() { return p_; }
const void *get() const { return p_; }