summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/Util.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2003-10-21 20:40:01 +0000
committerBernard Normier <bernard@zeroc.com>2003-10-21 20:40:01 +0000
commit2cb10f33a1cc8d3d94450fa45cc8f63ba32c137f (patch)
treeee83ca7fa800f497d1e7f340c5d1737545235870 /cpp/src/Freeze/Util.cpp
parentFixed code generation bug. (diff)
downloadice-2cb10f33a1cc8d3d94450fa45cc8f63ba32c137f.tar.bz2
ice-2cb10f33a1cc8d3d94450fa45cc8f63ba32c137f.tar.xz
ice-2cb10f33a1cc8d3d94450fa45cc8f63ba32c137f.zip
Added Freeze evictor indices
Diffstat (limited to 'cpp/src/Freeze/Util.cpp')
-rw-r--r--cpp/src/Freeze/Util.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/cpp/src/Freeze/Util.cpp b/cpp/src/Freeze/Util.cpp
new file mode 100644
index 00000000000..ebaca432024
--- /dev/null
+++ b/cpp/src/Freeze/Util.cpp
@@ -0,0 +1,77 @@
+// **********************************************************************
+//
+// Copyright (c) 2003
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+#include <Freeze/Util.h>
+#include <Freeze/Exception.h>
+
+using namespace Freeze;
+using namespace Ice;
+using namespace std;
+
+void
+Freeze::handleMemoryException(const DbMemoryException& dx, Key& key, Dbt& dbKey)
+{
+ if(dbKey.get_size() > dbKey.get_ulen())
+ {
+ //
+ // Keep the old key size in case it's used as input
+ //
+ size_t oldKeySize = key.size();
+
+ key.resize(dbKey.get_size());
+ initializeOutDbt(key, dbKey);
+ dbKey.set_size(oldKeySize);
+ }
+ else
+ {
+ //
+ // Real problem
+ //
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+}
+
+void
+Freeze::handleMemoryException(const DbMemoryException& dx, Key& key, Dbt& dbKey,
+ Value& value, Dbt& dbValue)
+{
+ bool resized = false;
+ if(dbKey.get_size() > dbKey.get_ulen())
+ {
+ size_t oldKeySize = key.size();
+ key.resize(dbKey.get_size());
+ initializeOutDbt(key, dbKey);
+ dbKey.set_size(oldKeySize);
+ resized = true;
+ }
+
+ if(dbValue.get_size() > dbValue.get_ulen())
+ {
+ value.resize(dbValue.get_size());
+ initializeOutDbt(value, dbValue);
+ resized = true;
+ }
+
+ if(!resized)
+ {
+ //
+ // Real problem
+ //
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+}