diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-11 08:25:30 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-10-14 13:12:02 +0200 |
commit | d8227f949940cd83ebf7d349b1e97d116474758b (patch) | |
tree | 807a400d92462072004a2c431e94aa999dc5bb0b /odb/oracle/details/number.cxx | |
parent | 6a2421094edb84224b0c7d02690522f3f7b8a86c (diff) |
Allow for size to be returned from big_int set_image functions
The OCI interface requires size information for any buffer passed to its bind
interface. By adding a return path for this data, we avert any need to obtain
this from the actual VARNUM binary data using messy byte manipulation.
Diffstat (limited to 'odb/oracle/details/number.cxx')
-rw-r--r-- | odb/oracle/details/number.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/odb/oracle/details/number.cxx b/odb/oracle/details/number.cxx index 044a99b..d328b1f 100644 --- a/odb/oracle/details/number.cxx +++ b/odb/oracle/details/number.cxx @@ -102,7 +102,7 @@ namespace odb } void - int64_to_number (char* b, long long v) + int64_to_number (char* b, size_t& n, long long v) { // We assume that b is long enough to contain a long long VARNUM // representation, that being 12 bytes. @@ -121,8 +121,8 @@ namespace odb } bool sig (false); - size_t n (0); unsigned char t[11], *m (t); + n = 0; if (v < 0) { @@ -169,6 +169,7 @@ namespace odb // Set the length. // ub[0] = static_cast<unsigned char> (m - t + 1); + n = static_cast<size_t> (ub[0] + 1); // Set the significant digits in big-endian byte order and the // terminator, if any. @@ -227,7 +228,7 @@ namespace odb } void - uint64_to_number (char* b, unsigned long long v) + uint64_to_number (char* b, size_t& n, unsigned long long v) { // We assume that b is long enough to contain an unsigned long long // VARNUM representation, that being 12 bytes. @@ -246,8 +247,8 @@ namespace odb } bool sig (false); - size_t n (0); unsigned char t[11], *m (t); + n = 0; while (v != 0) { @@ -268,6 +269,7 @@ namespace odb // Set the length. // ub[0] = static_cast<unsigned char> (m - t + 1); + n = static_cast<size_t> (ub[0] + 1); // Set the significant digits in big-endian byte order. // |