remove GrowingBuffer dependency from ED2KLink
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:54:56 +0000 (21:54 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 5 Jul 2008 19:54:56 +0000 (21:54 +0200)
ED2KLink.cpp
Makefile

index 47f3af8..5f33ce8 100644 (file)
@@ -6,7 +6,6 @@
 #include <stdlib.h>
 #include <string.h>
 #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);
index f565aa5..194e019 100644 (file)
--- 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