diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-06-18T09·34+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-06-18T09·34+0000 |
commit | a72709afd8ffe35613a6bacd698a36395e095a48 (patch) | |
tree | 2f549bafbed92a53bd6faea1da43667307af7593 /src/libutil/serialise.cc | |
parent | 934c58aa381f5eacc86304ba7f5c6775ff456cd5 (diff) |
* Some refactoring: put the GC options / results in separate structs.
* The garbage collector now also prints the number of blocks freed.
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r-- | src/libutil/serialise.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc index c3fd4dd10cc8..c13e8c7e38e5 100644 --- a/src/libutil/serialise.cc +++ b/src/libutil/serialise.cc @@ -41,6 +41,21 @@ void writeInt(unsigned int n, Sink & sink) } +void writeLongLong(unsigned long long n, Sink & sink) +{ + unsigned char buf[8]; + buf[0] = n & 0xff; + buf[1] = (n >> 8) & 0xff; + buf[2] = (n >> 16) & 0xff; + buf[3] = (n >> 24) & 0xff; + buf[4] = (n >> 32) & 0xff; + buf[5] = (n >> 40) & 0xff; + buf[6] = (n >> 48) & 0xff; + buf[7] = (n >> 56) & 0xff; + sink(buf, sizeof(buf)); +} + + void writeString(const string & s, Sink & sink) { unsigned int len = s.length(); @@ -84,6 +99,22 @@ unsigned int readInt(Source & source) } +unsigned long long readLongLong(Source & source) +{ + unsigned char buf[8]; + source(buf, sizeof(buf)); + return + ((unsigned long long) buf[0]) | + ((unsigned long long) buf[1] << 8) | + ((unsigned long long) buf[2] << 16) | + ((unsigned long long) buf[3] << 24) | + ((unsigned long long) buf[4] << 32) | + ((unsigned long long) buf[5] << 40) | + ((unsigned long long) buf[6] << 48) | + ((unsigned long long) buf[7] << 56); +} + + string readString(Source & source) { unsigned int len = readInt(source); |