Reverted contributions by jmucchiello

This commit is contained in:
Sergey Lyubka 2013-08-19 11:54:47 +01:00
parent a58e82b301
commit 85209ac4fa
2 changed files with 16 additions and 43 deletions

View File

@ -955,8 +955,6 @@ static void send_http_error(struct mg_connection *conn, int status,
int len = 0;
conn->status_code = status;
if (conn->ctx->callbacks.http_error == NULL ||
conn->ctx->callbacks.http_error(conn, status)) {
buf[0] = '\0';
// Errors 1xx, 204 and 304 MUST NOT send a body
@ -976,7 +974,6 @@ static void send_http_error(struct mg_connection *conn, int status,
suggest_connection_header(conn));
conn->num_bytes_sent += mg_printf(conn, "%s", buf);
}
}
#if defined(_WIN32) && !defined(__SYMBIAN32__)
static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
@ -1628,24 +1625,6 @@ int mg_write(struct mg_connection *conn, const void *buf, size_t len) {
return (int) total;
}
// Alternative alloc_vprintf() for non-compliant C runtimes
static int alloc_vprintf2(char **buf, const char *fmt, va_list ap) {
va_list ap_copy;
int size = MG_BUF_LEN;
int len = -1;
*buf = NULL;
while (len == -1) {
if (*buf) free(*buf);
*buf = malloc(size *= 4);
if (!*buf) break;
va_copy(ap_copy, ap);
len = vsnprintf(*buf, size, fmt, ap_copy);
}
return len;
}
// Print message to buffer. If buffer is large enough to hold the message,
// return buffer. If buffer is to small, allocate large enough buffer on heap,
// and return allocated buffer.
@ -1661,12 +1640,7 @@ static int alloc_vprintf(char **buf, size_t size, const char *fmt, va_list ap) {
va_copy(ap_copy, ap);
len = vsnprintf(NULL, 0, fmt, ap_copy);
if (len < 0) {
// C runtime is not standard compliant, vsnprintf() returned -1.
// Switch to alternative code path that uses incremental allocations.
va_copy(ap_copy, ap);
len = alloc_vprintf2(buf, fmt, ap);
} else if (len > (int) size &&
if (len > (int) size &&
(size = len + 1) > 0 &&
(*buf = (char *) malloc(size)) == NULL) {
len = -1; // Allocation failed, mark failure

View File

@ -120,7 +120,6 @@ struct mg_callbacks {
// Implementing this callback allows to create custom error pages.
// Parameters:
// status: HTTP error status code.
int (*http_error)(struct mg_connection *, int status);
};
// Start web server.