From 2af3846ddfed014db669d3b7823d68f85a26e50d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 5 Jul 2008 19:20:24 +0200 Subject: [PATCH] simplify add logging --- ED2KLink.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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() { -- 2.7.4