]> git.notmuchmail.org Git - apitrace/commitdiff
Pickle blobs as bytearrays.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 17 Mar 2012 16:12:22 +0000 (16:12 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 17 Mar 2012 16:12:22 +0000 (16:12 +0000)
cli/cli_pickle.cpp
common/pickle.hpp

index e3222dbbdc37500119a857df908c36a90244ea05..9145f448afde5ae42603dd6c817df097c1595f4e 100644 (file)
@@ -145,7 +145,7 @@ public:
     }
 
     void visit(Blob *node) {
-        writer.writeString((const char *)node->buf, node->size);
+        writer.writeByteArray(node->buf, node->size);
     }
 
     void visit(Pointer *node) {
index 736025b2a1cd8b3ee6583e8bfac336b30edad876..60694fa83d92d8da1e9891e6865574d13d7e0ea2 100644 (file)
@@ -268,6 +268,16 @@ public:
         os.put(u.c[0]);
     }
 
+    inline void writeByteArray(const void *buf, size_t length) {
+        os.put(GLOBAL);
+        os << "__builtin__\nbytearray\n";
+        os.put(BINPUT);
+        os.put(1);
+        writeString(static_cast<const char *>(buf), length);
+        os.put(TUPLE1);
+        os.put(REDUCE);
+    }
+
 protected:
     inline void putInt16(uint16_t i) {
         os.put( i        & 0xff);