[ldlogger] Allocate arguments on heap by default.
Always allocate logger arguments on heap.
Static arguments array and size macro removed.
#include "ldlogger-hooks.h"
-#define CC_LOGGER_MAX_ARGS 4096
-
#define CC_LOGGER_CALL_EXEC(funName_, arglist, ...) \
tryLog(__VA_ARGS__); \
{ \
@@ -63,9 +61,7 @@ static void tryLog(
const char* const filename_,
char* const argv_[], ...)
{
- size_t i,argCount,isOnHeap;
- const char* staticLoggerArgs[CC_LOGGER_MAX_ARGS];
- const char** largeLoggerArgs;
+ size_t i,argCount;
const char** loggerArgs;
for (i = 0,argCount = 0; argv_[i]; ++i)
@@ -73,15 +69,7 @@ static void tryLog(
argCount++;
}
- isOnHeap = argCount >= (CC_LOGGER_MAX_ARGS - 1);
-
- if(isOnHeap) {
- largeLoggerArgs = (const char **) malloc(sizeof(char*) * (argCount + 2));
- loggerArgs = largeLoggerArgs;
- } else {
- largeLoggerArgs = NULL;
- loggerArgs = staticLoggerArgs;
- }
+ loggerArgs = (const char **) malloc(sizeof(char*) * (argCount + 2));
loggerArgs[0] = filename_;
for (i = 0; argv_[i]; ++i)
@@ -92,8 +80,7 @@ static void tryLog(
logExec(i+1, loggerArgs);
- if(isOnHeap && largeLoggerArgs != NULL)
- free(largeLoggerArgs);
+ free(loggerArgs);
}
__attribute__ ((visibility ("default"))) int execv(const char* filename_, char* const argv_[])
