From: David ‘Bombe’ Roden Date: Sat, 5 Jul 2008 17:20:24 +0000 (+0200) Subject: simplify X-Git-Tag: 0.1~37 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2af3846ddfed014db669d3b7823d68f85a26e50d;p=ecparse.git simplify add logging --- diff --git a/ED2KLink.cpp b/ED2KLink.cpp index 2b4d08a..eee0d69 100644 --- a/ED2KLink.cpp +++ b/ED2KLink.cpp @@ -8,7 +8,6 @@ #include "ED2KLink.h" #include "GrowingBuffer.h" #include "GlobalSettings.h" -#include "GlobalSettings.h" static int getDigits(size_t number) { int digits = 0; @@ -27,12 +26,13 @@ ED2KLink::ED2KLink(const char* filename, const size_t size, const void* hash) { memcpy(this->hash, hash, 16); this->size = size; - this->link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1); - sprintf(this->link, "ed2k://|file|%s|%u|", filename, size); + link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1); + sprintf(link, "ed2k://|file|%s|%u|", filename, size); for (int i = 0; i < 16; i++) { - sprintf(this->link + strlen(this->link), "%02x", *((int*) this->hash + i)); + sprintf(link + strlen(link), "%02x", *((int*) this->hash + i)); } - sprintf(this->link + strlen(this->link), "|/"); + sprintf(link + strlen(link), "|/"); + GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] created ed2kLink: %s\n", __FILE__, __LINE__, link); } ED2KLink::~ED2KLink() { @@ -48,7 +48,6 @@ ED2KLink::~ED2KLink() { } ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { - ED2KLink* ed2kLink; const char* tempBuffer = buffer; char* filename; char* sizeString; @@ -89,8 +88,7 @@ ED2KLink* ED2KLink::parseED2KLink(const char* buffer) { sscanf(tempBuffer, "%hhx", hash + hashIndex); } - ed2kLink = new ED2KLink(filename, size, hash); - return ed2kLink; + return new ED2KLink(filename, size, hash); } const char* ED2KLink::getLink() {