From 83171b7de14d99f3a213eec0192ba86ff71f9a72 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 21 Oct 2012 12:58:03 +0000 Subject: [PATCH] Replace the IOB_RESET() macro with the new function clear_iob() --- filters.c | 4 ++-- jcc.c | 8 ++++---- parsers.c | 23 ++++++++++++++++++++++- parsers.h | 3 ++- project.h | 8 +------- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/filters.c b/filters.c index ac35d4aa..a7f622a9 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.173 2012/10/05 12:15:39 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.174 2012/10/21 12:35:15 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -1692,7 +1692,7 @@ static char *pcrs_filter_response(struct client_state *csp) csp->flags |= CSP_FLAG_MODIFIED; csp->content_length = size; - IOB_RESET(csp->iob); + clear_iob(csp->iob); return(new); diff --git a/jcc.c b/jcc.c index 282523cf..cbad64fd 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.399 2012/10/21 12:53:33 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.400 2012/10/21 12:56:38 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1793,7 +1793,7 @@ static void chat(struct client_state *csp) { return; } - IOB_RESET(csp->client_iob); + clear_iob(csp->client_iob); } log_error(LOG_LEVEL_CONNECT, "to %s successful", http->hostport); @@ -2510,7 +2510,7 @@ static void prepare_csp_for_next_request(struct client_state *csp) csp->expected_content_length = 0; csp->expected_client_content_length = 0; list_remove_all(csp->headers); - IOB_RESET(csp->iob); + clear_iob(csp->iob); freez(csp->error_message); free_http_request(csp->http); destroy_list(csp->headers); @@ -2556,7 +2556,7 @@ static void prepare_csp_for_next_request(struct client_state *csp) * Freeing the buffer itself isn't technically necessary, * but makes debugging more convenient. */ - IOB_RESET(csp->client_iob); + clear_iob(csp->client_iob); } } #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ diff --git a/parsers.c b/parsers.c index 2ea779a5..db9527e1 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.256 2012/10/17 18:19:59 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.257 2012/10/21 12:39:27 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -359,6 +359,27 @@ jb_err add_to_iob(struct iob *iob, const size_t buffer_limit, char *src, long n) } +/********************************************************************* + * + * Function : clear_iob + * + * Description : Frees the memory allocated for an I/O buffer and + * resets the structure. + * + * Parameters : + * 1 : iob = I/O buffer to clear. + * + * Returns : JB_ERR_OK on success, JB_ERR_MEMORY if out-of-memory + * or buffer limit reached. + * + *********************************************************************/ +void clear_iob(struct iob *iob) +{ + free(iob->buf); + memset(iob, '\0', sizeof(*iob));; +} + + #ifdef FEATURE_ZLIB /********************************************************************* * diff --git a/parsers.h b/parsers.h index c8010688..ce774c91 100644 --- a/parsers.h +++ b/parsers.h @@ -1,6 +1,6 @@ #ifndef PARSERS_H_INCLUDED #define PARSERS_H_INCLUDED -#define PARSERS_H_VERSION "$Id: parsers.h,v 1.52 2012/09/04 08:33:31 fabiankeil Exp $" +#define PARSERS_H_VERSION "$Id: parsers.h,v 1.53 2012/10/21 12:39:27 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.h,v $ @@ -56,6 +56,7 @@ extern "C" { extern long flush_socket(jb_socket fd, struct iob *iob); extern jb_err add_to_iob(struct iob *iob, const size_t buffer_limit, char *src, long n); +extern void clear_iob(struct iob *iob); extern jb_err decompress_iob(struct client_state *csp); extern char *get_header(struct iob *iob); extern char *get_header_value(const struct list *header_list, const char *header_name); diff --git a/project.h b/project.h index 4ca2b529..62b95032 100644 --- a/project.h +++ b/project.h @@ -1,7 +1,7 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED /** Version string. */ -#define PROJECT_H_VERSION "$Id: project.h,v 1.187 2012/10/21 12:53:33 fabiankeil Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.188 2012/10/21 12:56:38 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -417,12 +417,6 @@ struct iob #define IOB_PEEK(IOB) ((IOB->cur > IOB->eod) ? (IOB->eod - IOB->cur) : 0) -/** - * Remove any data in the I/O buffer associated with the passed - * client_state pointer. - */ -#define IOB_RESET(IOB) do {free(IOB->buf); memset(IOB, '\0', sizeof(*IOB));} while (0) - /* Bits for csp->content_type bitmask: */ #define CT_TEXT 0x0001U /**< Suitable for pcrs filtering. */ #define CT_GIF 0x0002U /**< Suitable for GIF filtering. */ -- 2.39.2