Commit ad0316ef authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Stop copying file names that we get from apr_file_t's and apr_dir_t's.

We copy the data when we store it in the structures, we can just return
a pointer from there, and use const data.  This puts the onus back on
Apache to copy the data if it needs to modify it.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87592 13f79535-47bb-0310-9956-ffa450edef68
parent 62d79466
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
Changes with Apache 2.0b1

  *) Stop returning copies of filenames from both apr_file_t and
     apr_dir_t.  We pstrdup the filenames that we store in the
     actual structures, so we don't need to pstrdup the strings again.
     [Ryan Bloom]

  *) mod_cgi: Fix some problems where the wrong error value was being
     traced.  [Jeff Trawick]

+1 −1
Original line number Diff line number Diff line
@@ -1357,7 +1357,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
	return dav_new_error(pool, HTTP_NOT_FOUND, 0, NULL);
    }
    while ((apr_readdir(dirp)) == APR_SUCCESS) {
	char *name;
	const char *name;
	apr_size_t len;

	apr_get_dir_filename(&name, dirp);
+2 −2
Original line number Diff line number Diff line
@@ -1157,7 +1157,7 @@ static char *find_title(request_rec *r)
    return NULL;
}

static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
static struct ent *make_autoindex_entry(const char *name, int autoindex_opts,
					autoindex_config_rec *d,
					request_rec *r, char keyid,
					char direction)
@@ -1622,7 +1622,7 @@ static int index_directory(request_rec *r,
     */
    head = NULL;
    while (apr_readdir(d) == APR_SUCCESS) {
        char *d_name;
        const char *d_name;
        apr_get_dir_filename(&d_name, d);
	p = make_autoindex_entry(d_name, autoindex_opts,
				 autoindex_conf, r, keyid, direction);
+1 −1
Original line number Diff line number Diff line
@@ -938,7 +938,7 @@ static int read_types_multi(negotiation_state *neg)

    while (apr_readdir(dirp) == APR_SUCCESS) {
        request_rec *sub_req;
        char *d_name;
        const char *d_name;

        apr_get_dir_filename(&d_name, dirp);
        /* Do we have a match? */
+5 −8
Original line number Diff line number Diff line
@@ -236,7 +236,8 @@ static int sort_by_quality(const void *left, const void *rite)
static int check_speling(request_rec *r)
{
    spconfig *cfg;
    char *good, *bad, *postgood, *url, *fname;
    char *good, *bad, *postgood, *url;
    const char *fname;
    int filoc, dotloc, urlen, pglen;
    apr_array_header_t *candidates = NULL;
    apr_dir_t          *dir;
@@ -309,10 +310,6 @@ static int check_speling(request_rec *r)
        dotloc = strlen(bad);
    }

    /* NOTE: apr_get_dir_filename() fills fname with a apr_palloc()ed copy
     * of the found directory name already. We don't need to copy it.
     * @@@: Copying *ALL* found file names is wasted energy (and memory)!
     */
    while (apr_readdir(dir) == APR_SUCCESS &&
	   apr_get_dir_filename(&fname, dir) == APR_SUCCESS) {
        sp_reason q;
@@ -335,7 +332,7 @@ static int check_speling(request_rec *r)
            misspelled_file *sp_new;

	    sp_new = (misspelled_file *) apr_push_array(candidates);
            sp_new->name = fname;
            sp_new->name = apr_pstrdup(r->pool, fname);
            sp_new->quality = SP_MISCAPITALIZED;
        }

@@ -347,7 +344,7 @@ static int check_speling(request_rec *r)
            misspelled_file *sp_new;

	    sp_new = (misspelled_file *) apr_push_array(candidates);
            sp_new->name = fname;
            sp_new->name = apr_pstrdup(r->pool, fname);
            sp_new->quality = q;
        }

@@ -393,7 +390,7 @@ static int check_speling(request_rec *r)
                misspelled_file *sp_new;

		sp_new = (misspelled_file *) apr_push_array(candidates);
                sp_new->name = fname;
                sp_new->name = apr_pstrdup(r->pool, fname);
                sp_new->quality = SP_VERYDIFFERENT;
            }
#endif
Loading