1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

made some char * into const char * and I removed the check for size > 0

in the add_buffer function.
This commit is contained in:
Daniel Stenberg 2001-08-14 08:28:15 +00:00
parent f195502064
commit c11a1bf72a

View File

@ -104,7 +104,7 @@
* be sent in one go.
*/
static CURLcode
add_buffer(send_buffer *in, void *inptr, size_t size);
add_buffer(send_buffer *in, const void *inptr, size_t size);
/*
* add_buffer_init() returns a fine buffer struct
@ -148,7 +148,7 @@ size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
* add_bufferf() builds a buffer from the formatted input
*/
static
CURLcode add_bufferf(send_buffer *in, char *fmt, ...)
CURLcode add_bufferf(send_buffer *in, const char *fmt, ...)
{
CURLcode result = CURLE_OUT_OF_MEMORY;
char *s;
@ -168,32 +168,30 @@ CURLcode add_bufferf(send_buffer *in, char *fmt, ...)
* add_buffer() appends a memory chunk to the existing one
*/
static
CURLcode add_buffer(send_buffer *in, void *inptr, size_t size)
CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
{
char *new_rb;
int new_size;
if(size > 0) {
if(!in->buffer ||
((in->size_used + size) > (in->size_max - 1))) {
new_size = (in->size_used+size)*2;
if(in->buffer)
/* we have a buffer, enlarge the existing one */
new_rb = (char *)realloc(in->buffer, new_size);
else
/* create a new buffer */
new_rb = (char *)malloc(new_size);
if(!in->buffer ||
((in->size_used + size) > (in->size_max - 1))) {
new_size = (in->size_used+size)*2;
if(in->buffer)
/* we have a buffer, enlarge the existing one */
new_rb = (char *)realloc(in->buffer, new_size);
else
/* create a new buffer */
new_rb = (char *)malloc(new_size);
if(!new_rb)
return CURLE_OUT_OF_MEMORY;
if(!new_rb)
return CURLE_OUT_OF_MEMORY;
in->buffer = new_rb;
in->size_max = new_size;
}
memcpy(&in->buffer[in->size_used], inptr, size);
in->size_used += size;
in->buffer = new_rb;
in->size_max = new_size;
}
memcpy(&in->buffer[in->size_used], inptr, size);
in->size_used += size;
return CURLE_OK;
}
@ -240,7 +238,7 @@ int GetLine(int sockfd, char *buf, struct connectdata *conn)
* This function checks the linked list of custom HTTP headers for a particular
* header (prefix).
*/
bool static checkheaders(struct UrlData *data, char *thisheader)
static bool checkheaders(struct UrlData *data, const char *thisheader)
{
struct curl_slist *head;
size_t thislen = strlen(thisheader);