diff --git a/lib/sendf.c b/lib/sendf.c index 40d56d5a443d40f2de4a354678455ab701d5e27c..5b7a6beb31ef0810957b3a0ff8986415123d2745 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -559,10 +559,6 @@ int Curl_read_plain(curl_socket_t sockfd, return CURLE_OK; } -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - /* * Internal read-from-socket function. This is meant to deal with plain * sockets, SSL sockets and kerberos sockets. @@ -591,7 +587,7 @@ int Curl_read(struct connectdata *conn, /* connection data */ /* If session can pipeline, check connection buffer */ if(pipelining) { - size_t bytestocopy = MIN(conn->buf_len - conn->read_pos, sizerequested); + size_t bytestocopy = CURLMIN(conn->buf_len - conn->read_pos, sizerequested); /* Copy from our master buffer first if we have some unread data there*/ if(bytestocopy > 0) { @@ -604,11 +600,11 @@ int Curl_read(struct connectdata *conn, /* connection data */ } /* If we come here, it means that there is no data to read from the buffer, * so we read from the socket */ - bytesfromsocket = MIN(sizerequested, BUFSIZE * sizeof (char)); + bytesfromsocket = CURLMIN(sizerequested, BUFSIZE * sizeof (char)); buffertofill = conn->master_buffer; } else { - bytesfromsocket = MIN((long)sizerequested, conn->data->set.buffer_size ? + bytesfromsocket = CURLMIN((long)sizerequested, conn->data->set.buffer_size ? conn->data->set.buffer_size : BUFSIZE); buffertofill = buf; } diff --git a/lib/transfer.c b/lib/transfer.c index 58279946ddf2ef7291d0b3aede0736ace48e76d5..43a9cc2944dee36ee6f599bdc1cdf3119dab24eb 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -323,10 +323,6 @@ static int data_pending(const struct connectdata *conn) Curl_ssl_data_pending(conn, FIRSTSOCKET); } -#ifndef MIN -#define MIN(a,b) (a < b ? a : b) -#endif - static void read_rewind(struct connectdata *conn, size_t thismuch) { @@ -338,7 +334,7 @@ static void read_rewind(struct connectdata *conn, char buf[512 + 1]; size_t show; - show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1); + show = CURLMIN(conn->buf_len - conn->read_pos, sizeof(buf)-1); if(conn->master_buffer) { memcpy(buf, conn->master_buffer + conn->read_pos, show); buf[show] = '\0'; diff --git a/lib/urldata.h b/lib/urldata.h index 029e9f78d26e4025243dbd28355e2d0099e4b340..047b877d96ee378ff39e8b247e1ed68b8874257b 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -150,9 +150,11 @@ #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU -/* Just a convenience macro to get the larger value out of two given. +/* Some convenience macros to get the larger/smaller value out of two given. We prefix with CURL to prevent name collisions. */ #define CURLMAX(x,y) ((x)>(y)?(x):(y)) +#define CURLMIN(x,y) ((x)<(y)?(x):(y)) + #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI) /* Types needed for krb4/5-ftp connections */ diff --git a/src/main.c b/src/main.c index de785216800e2ad2aa8a77a405a16346a09c4af6..f8e53384dc8945031e1ff0fae12e05f73ef0f3d7 100644 --- a/src/main.c +++ b/src/main.c @@ -184,14 +184,6 @@ char **__crt0_glob_function (char *arg) #define CURL_PROGRESS_STATS 0 /* default progress display */ #define CURL_PROGRESS_BAR 1 -/** - * @def MIN - * standard MIN macro - */ -#ifndef MIN -#define MIN(X,Y) (((X) < (Y)) ? (X) : (Y)) -#endif - typedef enum { HTTPREQ_UNSPEC, HTTPREQ_GET,