#define _SW SECURE_SLOGW
#define _SE SECURE_SLOGE
+#define E_STR_ALLOC RED("Memory allocation failed")
+#define _E_ALLOC _E(E_STR_ALLOC)
+
/* Color code for dlog */
#define RED(X) "\033[0;31m" X "\033[0m"
#define GREEN(X) "\033[0;32m" X "\033[0m"
ResultCbData* cbData = new(std::nothrow) ResultCbData;
if (!cbData) {
g_variant_unref(inParam);
- _E("Memory allocation failed");
+ _E_ALLOC;
return E_NO_MEM;
}
} else {
builder.add(__toString(value[i]));
}
- } catch(std::exception& e) {
+ } catch (const std::exception& e) {
builder.add(__toString(value[i]));
}
}
try {
cbData->queryResult->push_back(builder.build());
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
_E("Exception: %s", e.what());
return E_FAILED;
}
_SD("%s", query.c_str());
ExecutionCbData* cbData = new(std::nothrow) ExecutionCbData(&columnTypes, columnNames, queryResult);
- IF_FAIL_RETURN_TAG(cbData, false, _E, "Memory allocation failed");
+ IF_FAIL_RETURN_TAG(cbData, false, _E, E_STR_ALLOC);
char* err = NULL;
int ret = sqlite3_exec(__dbHandle, query.c_str(), __executionCb, cbData, &err);
if (__credential)
return true;
- __credential = new(std::nothrow) Credential(__hostService->getConnection(), __busName);
- IF_FAIL_RETURN_TAG(__credential, false, _E, "Memory allocation failed");
+ __credential = new Credential(__hostService->getConnection(), __busName);
return true;
}
IF_FAIL_VOID(__threadRunning.load());
GSource* gSrc = g_idle_source_new();
- IF_FAIL_VOID_TAG(gSrc, _E, "Memory allocation failed");
+ IF_FAIL_VOID_TAG(gSrc, _E, E_STR_ALLOC);
g_source_set_callback(gSrc, __onUserActivated, this, NULL);
g_source_attach(gSrc, __mainContext);
IF_FAIL_VOID(__threadRunning.load());
GSource* gSrc = g_idle_source_new();
- IF_FAIL_VOID_TAG(gSrc, _E, "Memory allocation failed");
+ IF_FAIL_VOID_TAG(gSrc, _E, E_STR_ALLOC);
g_source_set_callback(gSrc, __onUserDeactivated, this, NULL);
g_source_attach(gSrc, __mainContext);
ClientBase* client = __getClient(sender);
IF_FAIL_VOID(client);
- MethodCall* methodCall = new(std::nothrow) MethodCall(client, name, param, invocation);
- IF_FAIL_VOID_TAG(methodCall, _E, "Memory allocation failed");
-
- client->onMethodCalled(methodCall);
+ client->onMethodCalled(new MethodCall(client, name, param, invocation));
}
ClientBase* ServiceBase::__getClient(const std::string& busName)
return iter->second.client;
ClientBase* client = createClient(busName);
- IF_FAIL_RETURN_TAG(client, NULL, _E, "Memory allocation failed");
+ IF_FAIL_RETURN_TAG(client, NULL, _E, "Client creation failed");
if (!client->isVerified()) {
delete client;
{
INIT_CONTEXT;
- ListenerInfo* info = new(std::nothrow) ListenerInfo(this, listener);
- IF_FAIL_RETURN_TAG(info, 0, _E, "Memory allocation failed");
-
GSource* gSrc = g_idle_source_new();
- if (!gSrc) {
- _E("Memory allocation failed");
- delete info;
- return 0;
- }
+ IF_FAIL_RETURN_TAG(gSrc, 0, _E, E_STR_ALLOC);
+
+ ListenerInfo* info = new ListenerInfo(this, listener);
info->timerId = TIMER_ID;
info->gSrc = gSrc;
{
INIT_CONTEXT;
- ListenerInfo* info = new(std::nothrow) ListenerInfo(this, listener);
- IF_FAIL_RETURN_TAG(info, 0, _E, "Memory allocation failed");
-
GSource* gSrc = g_timeout_source_new(intervalMs);
- if (!gSrc) {
- _E("Memory allocation failed");
- delete info;
- return 0;
- }
+ IF_FAIL_RETURN_TAG(gSrc, 0, _E, E_STR_ALLOC);
+
+ ListenerInfo* info = new ListenerInfo(this, listener);
info->timerId = TIMER_ID;
info->intervalMs = intervalMs;
int alarmId, result;
- ListenerInfo* info = new(std::nothrow) ListenerInfo(this, listener);
- IF_FAIL_RETURN_TAG(info, 0, _E, "Memory allocation failed");
+ ListenerInfo* info = new ListenerInfo(this, listener);
info->intervalMs = intervalMin * MILLIS_PER_MIN;
_D("Id: %u (%d), Interval: %u ms", info->timerId, info->alarmId, info->intervalMs);
GSource* gSrc = g_idle_source_new();
- IF_FAIL_RETURN_TAG(gSrc, 0, _E, "Memory allocation failed");
+ IF_FAIL_RETURN_TAG(gSrc, 0, _E, E_STR_ALLOC);
g_source_set_callback(gSrc, __onAlarmExpired, userData, NULL);
g_source_attach(gSrc, info->timer->__context);
std::vector<std::string> tokens;
char* inputStr = g_strdup(in.c_str());
- IF_FAIL_RETURN_TAG(inputStr, tokens, _E, "Memory allocation failed");
+ IF_FAIL_RETURN_TAG(inputStr, tokens, _E, E_STR_ALLOC);
char* savePtr = NULL;
char* token = strtok_r(inputStr, delim, &savePtr);
__elements = new(std::nothrow) GVariant*[__numElements];
if (!__elements) {
__numElements = 0;
- _E("Memory allocation failed");
+ _E_ALLOC;
return false;
}
try {
return std::make_shared<Tuple>(gv);
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
_E("Exception: %s", e.what());
g_variant_unref(gv);
throw;
if (g_variant_is_of_type(gVar, G_VARIANT_TYPE_TUPLE)) {
try {
tuples.push_back(std::make_shared<Tuple>(gVar));
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
_E("Exception: %s", e.what());
g_variant_unref(gVar);
}
}
try {
tuples.push_back(std::make_shared<Tuple>(child));
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
_E("Exception: %s", e.what());
g_variant_unref(child);
}
{
if (!__gvBuilder) {
__gvBuilder = g_variant_builder_new(G_VARIANT_TYPE_TUPLE);
- IF_FAIL_RETURN_TAG(__gvBuilder, false, _E, "Memory allocation failed");
+ IF_FAIL_RETURN_TAG(__gvBuilder, false, _E, E_STR_ALLOC);
}
return true;
}
try {
return std::make_shared<Tuple>(gVar);
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
_E("Exception: %s", e.what());
g_variant_unref(gVar);
throw;