Commit 85724e8f authored by Rafaël Carré's avatar Rafaël Carré

httpd: simplify MsgAdd

parent f170a378
......@@ -1297,36 +1297,30 @@ const char *httpd_MsgGet( const httpd_message_t *msg, const char *name )
void httpd_MsgAdd( httpd_message_t *msg, const char *name, const char *psz_value, ... )
{
va_list args;
char *value = NULL;
httpd_header *p_tmp = realloc( msg->p_headers, sizeof(httpd_header) * (msg->i_headers + 1));
if (!p_tmp)
return;
va_start( args, psz_value );
if( us_vasprintf( &value, psz_value, args ) == -1 )
value = NULL;
va_end( args );
msg->p_headers = p_tmp;
if( value == NULL )
httpd_header *h = &msg->p_headers[msg->i_headers];
h->name = strdup(name);
if (!h->name)
return;
name = strdup( name );
if( name == NULL )
{
free( value );
h->value = NULL;
va_list args;
va_start( args, psz_value );
int ret = us_vasprintf(&h->value, psz_value, args);
va_end( args );
if (ret == -1 ) {
free(h->name);
return;
}
httpd_header * p_tmp = realloc( msg->p_headers, sizeof(httpd_header) * (msg->i_headers + 1));
if(p_tmp)
{
msg->p_headers = p_tmp;
msg->p_headers[msg->i_headers].name = name;
msg->p_headers[msg->i_headers].value = value;
msg->i_headers++;
}
else
{
free(name);
free(value);
}
msg->i_headers++;
}
static void httpd_ClientInit( httpd_client_t *cl, mtime_t now )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment