From a275eab10f248a04881dae24c0f9f51138d1fb57 Mon Sep 17 00:00:00 2001 From: Andrew McNab Date: Mon, 5 Jun 2006 12:00:26 +0000 Subject: [PATCH] Use pools --- org.gridsite.core/CHANGES | 4 ++++ org.gridsite.core/src/mod_gridsite.c | 21 ++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/org.gridsite.core/CHANGES b/org.gridsite.core/CHANGES index 644c4f4..e088022 100644 --- a/org.gridsite.core/CHANGES +++ b/org.gridsite.core/CHANGES @@ -1,3 +1,7 @@ +* Mon Jun 05 2006 Andrew McNab +- Remove malloc/free for header/footer in mod_gridsite +* Mon Jun 05 2006 Andrew McNab +- ==== GridSite version 1.2.2 ==== * Fri May 26 2006 Andrew McNab - ==== GridSite version 1.2.1 ==== * Mon Apr 24 2006 Andrew McNab diff --git a/org.gridsite.core/src/mod_gridsite.c b/org.gridsite.core/src/mod_gridsite.c index 36efc51..1321eec 100644 --- a/org.gridsite.core/src/mod_gridsite.c +++ b/org.gridsite.core/src/mod_gridsite.c @@ -404,7 +404,8 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) /* first make a buffer big enough to hold path names we want to try */ fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); + s = apr_palloc(r->pool, + strlen(r->filename) + strlen(conf->headfile) + 1); strcpy(s, r->filename); for (;;) @@ -420,8 +421,6 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; } - free(s); - if (fd == -1) /* not found, so set up not to output one */ { head_formatted = apr_pstrdup(r->pool, ""); @@ -482,7 +481,8 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) /* first make a buffer big enough to hold path names we want to try */ fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->footfile)); + s = apr_palloc(r->pool, + strlen(r->filename) + strlen(conf->footfile) + 1); strcpy(s, r->filename); for (;;) @@ -499,8 +499,6 @@ int html_format(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; } - free(s); - if (fd == -1) /* failed to find a footer, so set up empty default */ { footer_formatted = apr_pstrdup(r->pool, ""); @@ -550,7 +548,6 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) struct dirent **namelist; if (r->finfo.filetype == APR_NOFILE) return HTTP_NOT_FOUND; - /* Put in Delegation service header if required */ if (conf->delegationuri) delegation_header(r, conf); @@ -564,7 +561,8 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) /* first make a buffer big enough to hold path names we want to try */ fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->headfile) + 1); + s = apr_palloc(r->pool, + strlen(r->filename) + strlen(conf->headfile) + 1); strcpy(s, r->filename); for (;;) @@ -580,8 +578,6 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; } - free(s); - if (fd == -1) /* not found, so set up to output sensible default */ { header_formatted = apr_pstrdup(r->pool, ""); @@ -679,7 +675,8 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) /* first make a buffer big enough to hold path names we want to try */ fd = -1; - s = malloc(strlen(r->filename) + strlen(conf->footfile)); + s = apr_palloc(r->pool, + strlen(r->filename) + strlen(conf->footfile) + 1); strcpy(s, r->filename); for (;;) @@ -696,8 +693,6 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf) *p = '\0'; } - free(s); - if (fd == -1) /* failed to find a footer, so use standard default */ { footer_formatted = apr_pstrdup(r->pool, ""); -- 1.8.2.3