From 123951f2009e356a8c4a2f834252c5d974c36558 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 5 Jul 2008 21:54:56 +0200 Subject: [PATCH] remove GrowingBuffer dependency from ED2KLink --- ED2KLink.cpp | 21 +++++++++------------ Makefile | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ED2KLink.cpp b/ED2KLink.cpp index 47f3af8..5f33ce8 100644 --- a/ED2KLink.cpp +++ b/ED2KLink.cpp @@ -6,7 +6,6 @@ #include #include #include "ED2KLink.h" -#include "GrowingBuffer.h" #include "GlobalSettings.h" static int getDigits(size_t number) { @@ -55,7 +54,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { int hashIndex; unsigned char hash[16]; char* pipeIndex; - GrowingBuffer growingBuffer; + int stringLength; GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] trying to parse “%s”...\n", __FILE__, __LINE__, buffer); @@ -69,11 +68,10 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] expected pipe character (‘|’) but found none.\n", __FILE__, __LINE__); return NULL; } - growingBuffer.write(tempBuffer, (char*) pipeIndex - tempBuffer); - filename = (char*) malloc(growingBuffer.getLimit() + 1); - growingBuffer.read(filename, growingBuffer.getLimit()); - sizeString[growingBuffer.getLimit()] = '\0'; - growingBuffer.clear(); + stringLength = (char*) pipeIndex - tempBuffer; + filename = (char*) malloc(stringLength + 1); + memcpy(filename, tempBuffer, stringLength); + sizeString[stringLength] = '\0'; tempBuffer = pipeIndex + 1; GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] parsed filename: “%s”.\n", __FILE__, __LINE__, filename); @@ -83,11 +81,10 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] expected pipe character (‘|’) but found none.\n", __FILE__, __LINE__); return NULL; } - growingBuffer.write(tempBuffer, (char*) pipeIndex - tempBuffer); - sizeString = (char*) malloc(growingBuffer.getLimit() + 1); - growingBuffer.read(sizeString, growingBuffer.getLimit()); - sizeString[growingBuffer.getLimit()] = '\0'; - growingBuffer.clear(); + stringLength = (char*) pipeIndex - tempBuffer; + sizeString = (char*) malloc(stringLength + 1); + memcpy(sizeString, tempBuffer, stringLength); + sizeString[stringLength] = '\0'; tempBuffer = pipeIndex + 1; size = atol(sizeString); diff --git a/Makefile b/Makefile index f565aa5..194e019 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ FileReaderInput.o: FileReaderInput.cpp FileReaderInput.h ReaderInput.h CollectionReader.o: CollectionReader.cpp ReaderInput.h ED2KLink.h GrowingBuffer.h GlobalSettings.h -ED2KLink.o: ED2KLink.cpp ED2KLink.h GrowingBuffer.h GlobalSettings.h +ED2KLink.o: ED2KLink.cpp ED2KLink.h GlobalSettings.h Main.o: Main.cpp FileReaderInput.h ReaderInput.h CollectionReader.h ED2KLink.h GlobalSettings.h Version.h -- 2.7.4