diff options
author | Guillaume Denneulin <guillaume.denneulin@intel.com> | 2013-12-03 14:27:41 +0100 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:04:16 +0100 |
commit | 2aab8716b2302c196349326a228e82b881d5fde3 (patch) | |
tree | 1f79d172ce41b6303f749ab9dd1e77ae25fde049 | |
parent | 1b8b3ca093ecd7dc8c1877352625508ca4a81728 (diff) | |
download | external_parameter-framework-2aab8716b2302c196349326a228e82b881d5fde3.zip external_parameter-framework-2aab8716b2302c196349326a228e82b881d5fde3.tar.gz external_parameter-framework-2aab8716b2302c196349326a228e82b881d5fde3.tar.bz2 |
[core] Optimize log handling.
BZ: 154623
When logging, the pfw was limited to 512 bytes.
Remove this limitation and optimize the buffer allocated.
Change-Id: I91537f30a519d93a4b1e55a23fe02f42dec3af8a
Signed-off-by: Guillaume Denneulin <guillaume.denneulin@intel.com>
-rwxr-xr-x[-rw-r--r--] | parameter/Element.cpp | 17 | ||||
-rwxr-xr-x[-rw-r--r--] | parameter/SubsystemObject.cpp | 16 |
2 files changed, 21 insertions, 12 deletions
diff --git a/parameter/Element.cpp b/parameter/Element.cpp index a96c683..b68205b 100644..100755 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -29,6 +29,7 @@ #include <assert.h> #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> #include <sstream> CElement::CElement(const string& strName) : _strName(strName), _pParent(NULL) @@ -43,30 +44,34 @@ CElement::~CElement() // Logging void CElement::log_info(const string& strMessage, ...) const { - char acBuffer[512]; + char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vsnprintf(acBuffer, sizeof(acBuffer), strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage.c_str(), listPointer); va_end(listPointer); - doLog(false, acBuffer); + doLog(false, pacBuffer); + + free(pacBuffer); } void CElement::log_warning(const string& strMessage, ...) const { - char acBuffer[512]; + char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vsnprintf(acBuffer, sizeof(acBuffer), strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage.c_str(), listPointer); va_end(listPointer); - doLog(true, acBuffer); + doLog(true, pacBuffer); + + free(pacBuffer); } // Log each element of the string list diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index 8c4e187..eaf87aa 100644..100755 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -190,30 +190,34 @@ void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize) // Logging void CSubsystemObject::log_info(const string& strMessage, ...) const { - char acBuffer[512]; + char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vsnprintf(acBuffer, sizeof(acBuffer), strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage.c_str(), listPointer); va_end(listPointer); - _pInstanceConfigurableElement->log_info(acBuffer); + _pInstanceConfigurableElement->log_info(pacBuffer); + + free(pacBuffer); } void CSubsystemObject::log_warning(const string& strMessage, ...) const { - char acBuffer[512]; + char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vsnprintf(acBuffer, sizeof(acBuffer), strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage.c_str(), listPointer); va_end(listPointer); - _pInstanceConfigurableElement->log_warning(acBuffer); + _pInstanceConfigurableElement->log_warning(pacBuffer); + + free(pacBuffer); } // Configurable element retrieval |