increase version number to 0.1
[ecparse.git] / GrowingBuffer.cpp
index 719e793..2d26251 100644 (file)
@@ -35,6 +35,10 @@ size_t GrowingBuffer::getSize() {
        return size;
 }
 
+size_t GrowingBuffer::getRemaining() {
+       return limit - position;
+}
+
 void GrowingBuffer::seek(size_t position) {
        this->position = (position > limit) ? limit : position;
        GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] setting position to %d.\n", __FILE__, __LINE__, position);
@@ -68,8 +72,8 @@ void GrowingBuffer::write(const void* buffer, size_t length) {
 }
 
 void GrowingBuffer::cut() {
-       GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] discarding %d bytes.\n", __FILE__, __LINE__, position);
-       memcpy(data, (char*) data + position, position);
+       GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] discarding %d bytes, %d bytes remaining.\n", __FILE__, __LINE__, position, limit - position);
+       memmove(data, (char*) data + position, limit);
        limit -= position;
        position = 0;
 }