bug fix
authorbdemsky <bdemsky@uci.edu>
Thu, 2 Nov 2017 00:10:49 +0000 (17:10 -0700)
committerbdemsky <bdemsky@uci.edu>
Thu, 2 Nov 2017 00:10:49 +0000 (17:10 -0700)
src/Serialize/serializer.cc
src/config.h
src/mymemory.h

index 4a97074..daa8ba0 100644 (file)
@@ -45,14 +45,18 @@ Serializer::~Serializer() {
 }
 
 void Serializer::mywrite(const void *__buf, size_t __n) {
+       char *towrite=(char *) __buf;
        if (__n > SERIALBUFFERLENGTH *2) {
                if (bufferoffset != 0)
                        flushBuffer();
-               ssize_t result=write(filedesc, __buf, __n);
-               if (result != (ssize_t) __n)
-                       exit(-1);
+               while (__n > 0) {
+                       ssize_t result=write(filedesc, &towrite, __n);
+                       if (result != (ssize_t) __n)
+                               exit(-1);
+                       towrite += result;
+                       __n -= result;
+               }
        } else {
-               char *towrite=(char *) __buf;
                do  {
                        uint spacefree = bufferlength-bufferoffset;
                        uint datatowrite = spacefree > __n ? __n : spacefree;
@@ -61,6 +65,7 @@ void Serializer::mywrite(const void *__buf, size_t __n) {
 
                        if (spacefree < __n) {
                                flushBuffer();
+                               __n -= datatowrite;
                                towrite += datatowrite;
                        } else if (spacefree == __n) {
                                flushBuffer();
index e34b828..2e48668 100644 (file)
@@ -19,7 +19,7 @@
 //#define CONFIG_DEBUG
 #endif
 
-#define SATCHECK_CONFIG
+//#define SATCHECK_CONFIG
 
 #ifndef CONFIG_ASSERT
 #define CONFIG_ASSERT
index 766e6f6..0798860 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "config.h"
 
-#define SATCHECK_CONFIG
+//#define SATCHECK_CONFIG
 
 /*
    void * ourmalloc(size_t size);