| 1122 | } |
| 1123 | |
| 1124 | int call::_callDebug(const char *fmt, ...) |
| 1125 | { |
| 1126 | va_list ap; |
| 1127 | |
| 1128 | if (!useCallDebugf) { |
| 1129 | return 0; |
| 1130 | } |
| 1131 | |
| 1132 | /* First we figure out how much to allocate. */ |
| 1133 | va_start(ap, fmt); |
| 1134 | int ret = vsnprintf(nullptr, 0, fmt, ap); |
| 1135 | va_end(ap); |
| 1136 | |
| 1137 | debugBuffer = (char *)realloc(debugBuffer, debugLength + ret + TIME_LENGTH + 2); |
| 1138 | if (!debugBuffer) { |
| 1139 | ERROR("Could not allocate buffer (%d bytes) for callDebug file!", debugLength + ret + TIME_LENGTH + 2); |
| 1140 | } |
| 1141 | |
| 1142 | struct timeval now; |
| 1143 | gettimeofday(&now, nullptr); |
| 1144 | debugLength += snprintf(debugBuffer + debugLength, TIME_LENGTH + 2, "%s ", CStat::formatTime(&now, rfc3339)); |
| 1145 | |
| 1146 | va_start(ap, fmt); |
| 1147 | debugLength += vsnprintf(debugBuffer + debugLength, ret + 1, fmt, ap); |
| 1148 | va_end(ap); |
| 1149 | |
| 1150 | return ret; |
| 1151 | } |
| 1152 | |
| 1153 | call::~call() |
| 1154 | { |