summaryrefslogtreecommitdiff
path: root/src/context/context_mm.cpp
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
committerMorgan Deters <mdeters@gmail.com>2010-03-05 08:26:37 +0000
commit88b52c971b43248e6ceacf1c8140a06427d0418d (patch)
tree4ee443c898a858fcdd658f3f043e4180eddd8784 /src/context/context_mm.cpp
parent29cc307cdf2c42bebf4f5615874a864783f47fd0 (diff)
* public/private code untangled (smt/smt_engine.h no longer #includes
expr/node.h). This removes the warnings we had during compilation, and heads off a number of potential linking errors due to improper inlining of private (library-only) stuff in client (out-of-library) code. * "configure" now takes some options as part of a "bare-option" build type (e.g., "./configure debug-coverage" or "./configure production-muzzle"). * split cdo.h, cdlist.h, cdmap.h, and cdset.h from context.h * split cdlist_black unit test from context_black * implement CDMap<>. * give ExprManagers ownership of the context (and have SmtEngine share that one) * fix main driver to properly report file-not-found * fix MemoryMappedInputBuffer class to report reasons for "errno"-returned system errors * src/expr/attribute.h: context-dependent attribute kinds now supported * test/unit/expr/node_white.h: context-dependent attribute tests * src/prop/cnf_conversion.h and associated parts of src/util/options.h and src/main/getopt.cpp: obsolete command-line option, removed. * src/util/Assert.h: assertions are now somewhat more useful (in debug builds, anyway) during stack unwinding. * test/unit/theory/theory_black.h: test context-dependent behavior of registerTerm() attribute for theories * src/expr/node_builder.h: formatting, fixes for arithmetic convenience node builders, check memory allocations * test/unit/expr/node_builder_black.h: add tessts for addition, subtraction, unary minus, and multiplication convenience node builders * src/expr/attribute.h: more comments * (various) code formatting, comment cleanup, added throws specifier to some destructors * contrib/code-checker: prototype perl script to test (some) code policy * contrib/indent-settings: command line for GNU indent to indent using CVC4 style (sort of; this is a work in progress) * COPYING: legal stuff * DESIGN_QUESTIONS: obsolete, removed
Diffstat (limited to 'src/context/context_mm.cpp')
-rw-r--r--src/context/context_mm.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/context/context_mm.cpp b/src/context/context_mm.cpp
index df7d82987..ab81c7486 100644
--- a/src/context/context_mm.cpp
+++ b/src/context/context_mm.cpp
@@ -32,9 +32,9 @@ void ContextMemoryManager::newChunk() {
"Index should be at the end of the list");
// Create new chunk if no free chunk available
- if (d_freeChunks.empty()) {
+ if(d_freeChunks.empty()) {
d_chunkList.push_back((char*)malloc(chunkSizeBytes));
- if (d_chunkList.back() == NULL) {
+ if(d_chunkList.back() == NULL) {
throw std::bad_alloc();
}
}
@@ -53,31 +53,32 @@ ContextMemoryManager::ContextMemoryManager() : d_indexChunkList(0) {
// Create initial chunk
d_chunkList.push_back((char*)malloc(chunkSizeBytes));
d_nextFree = d_chunkList.back();
- if (d_nextFree == NULL) {
+ if(d_nextFree == NULL) {
throw std::bad_alloc();
}
d_endChunk = d_nextFree + chunkSizeBytes;
}
-ContextMemoryManager::~ContextMemoryManager() {
+ContextMemoryManager::~ContextMemoryManager() throw() {
// Delete all chunks
- while (!d_chunkList.empty()) {
+ while(!d_chunkList.empty()) {
free(d_chunkList.back());
d_chunkList.pop_back();
}
- while (!d_freeChunks.empty()) {
+ while(!d_freeChunks.empty()) {
free(d_freeChunks.back());
d_freeChunks.pop_back();
}
}
+
void* ContextMemoryManager::newData(size_t size) {
// Use next available free location in current chunk
void* res = (void*)d_nextFree;
d_nextFree += size;
// Check if the request is too big for the chunk
- if (d_nextFree > d_endChunk) {
+ if(d_nextFree > d_endChunk) {
newChunk();
res = (void*)d_nextFree;
d_nextFree += size;
@@ -104,7 +105,7 @@ void ContextMemoryManager::pop() {
d_endChunkStack.pop_back();
// Free all the new chunks since the last push
- while (d_indexChunkList > d_indexChunkListStack.back()) {
+ while(d_indexChunkList > d_indexChunkListStack.back()) {
d_freeChunks.push_back(d_chunkList.back());
d_chunkList.pop_back();
--d_indexChunkList;
@@ -112,7 +113,7 @@ void ContextMemoryManager::pop() {
d_indexChunkListStack.pop_back();
// Delete excess free chunks
- while (d_freeChunks.size() > maxFreeChunks) {
+ while(d_freeChunks.size() > maxFreeChunks) {
free(d_freeChunks.front());
d_freeChunks.pop_front();
}
@@ -120,6 +121,4 @@ void ContextMemoryManager::pop() {
} /* CVC4::context namespace */
-
-
} /* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback