diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h index 9d188b0b86318c28ce428c332c765b7cf8726d2b..22d41a1a4d6dfff9f69543a571d13fd92697466b 100644 --- a/Common/GmshSocket.h +++ b/Common/GmshSocket.h @@ -80,8 +80,8 @@ class GmshSocket{ int remaining = bytes; do { int len = recv(_sock, buf + sofar, remaining, 0); - if(len <= 0) - return 0; + if(len == 0) break; // we're done! + if(len < 0) return -1; // error sofar += len; remaining -= len; } while(remaining > 0); diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp index e125aff23f382d5361638d42c08d01225a859c26..7faf3a52d718c968323637a582f7dc3250cc2c26 100644 --- a/Common/VertexArray.cpp +++ b/Common/VertexArray.cpp @@ -223,18 +223,13 @@ char *VertexArray::toChar(int num, int &len) int vs = vn * sizeof(float), ns = nn * sizeof(char), cs = cn * sizeof(unsigned char); int is = sizeof(int); - FILE *fp = fopen("toChar.txt", "w"); - for(unsigned int i = 0; i < _vertices.size(); i++) - fprintf(fp, "toChar vertex %d = %f\n", i, _vertices[i]); - fclose(fp); - len = 5 * is + vs + ns + cs; char *data = new char[len]; int index = 0; memcpy(&data[index], &num, is); index += is; memcpy(&data[index], &_numVerticesPerElement, is); index += is; memcpy(&data[index], &vn, is); index += is; - memcpy(&data[index], &_vertices[0], vs); index + vs; + memcpy(&data[index], &_vertices[0], vs); index += vs; memcpy(&data[index], &nn, is); index += is; memcpy(&data[index], &_normals[0], ns); index += ns; memcpy(&data[index], &cn, is); index += is; @@ -269,10 +264,4 @@ void VertexArray::fromChar(const char *data, bool swap) int cn; memcpy(&cn, &data[index], is); index += is; _colors.resize(cn); int cs = cn * sizeof(unsigned char); memcpy(&_colors[0], &data[index], cs); index += cs; - - - FILE *fp = fopen("fromChar.txt", "w"); - for(unsigned int i = 0; i < _vertices.size(); i++) - fprintf(fp, "from char vertex %d = %f\n", i, _vertices[i]); - fclose(fp); }