From: David ‘Bombe’ Roden Date: Sat, 5 Jul 2008 19:54:56 +0000 (+0200) Subject: remove GrowingBuffer dependency from ED2KLink X-Git-Tag: 0.1~22 X-Git-Url: https://git.pterodactylus.net/?p=ecparse.git;a=commitdiff_plain;h=123951f2009e356a8c4a2f834252c5d974c36558 remove GrowingBuffer dependency from ED2KLink --- 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