X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=GrowingBuffer.cpp;h=2d26251d66587b3335be8af9b0ce175cc0ae7cc8;hb=80ddd7c4c2b1e9965df13b552538415d3caf8a83;hp=719e793505ea9f6f204d1ffae9d2b7ac02735f6b;hpb=c3ba65b13afaf95a2e7ceadeea384ea32cfa0a22;p=ecparse.git diff --git a/GrowingBuffer.cpp b/GrowingBuffer.cpp index 719e793..2d26251 100644 --- a/GrowingBuffer.cpp +++ b/GrowingBuffer.cpp @@ -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; }