You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rb...@apache.org on 2001/01/05 20:40:06 UTC

cvs commit: apr/test testfile.c

rbb         01/01/05 11:40:06

  Modified:    .        CHANGES
               modules/dav/fs repos.c
               modules/generators mod_autoindex.c
               modules/mappers mod_negotiation.c mod_speling.c
               modules/test mod_autoindex.c
               server   config.c
               file_io/os2 dir.c
               file_io/unix dir.c
               file_io/win32 dir.c
               include  apr_file_io.h
               test     testfile.c
  Log:
  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.
  
  Revision  Changes    Path
  1.34      +5 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- CHANGES	2001/01/03 20:03:47	1.33
  +++ CHANGES	2001/01/05 19:40:00	1.34
  @@ -1,5 +1,10 @@
   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.40      +1 -1      httpd-2.0/modules/dav/fs/repos.c
  
  Index: repos.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/dav/fs/repos.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- repos.c	2000/12/17 03:35:37	1.39
  +++ repos.c	2001/01/05 19:40:01	1.40
  @@ -1357,7 +1357,7 @@
   	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);
  
  
  
  1.49      +2 -2      httpd-2.0/modules/generators/mod_autoindex.c
  
  Index: mod_autoindex.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_autoindex.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- mod_autoindex.c	2000/12/17 03:35:38	1.48
  +++ mod_autoindex.c	2001/01/05 19:40:02	1.49
  @@ -1157,7 +1157,7 @@
       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 @@
        */
       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.44      +1 -1      httpd-2.0/modules/mappers/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_negotiation.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- mod_negotiation.c	2000/12/17 03:35:38	1.43
  +++ mod_negotiation.c	2001/01/05 19:40:02	1.44
  @@ -938,7 +938,7 @@
   
       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? */
  
  
  
  1.23      +5 -8      httpd-2.0/modules/mappers/mod_speling.c
  
  Index: mod_speling.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_speling.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- mod_speling.c	2000/12/17 03:35:38	1.22
  +++ mod_speling.c	2001/01/05 19:40:03	1.23
  @@ -236,7 +236,8 @@
   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 @@
           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 @@
               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 @@
               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 @@
                   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
  
  
  
  1.4       +1 -1      httpd-2.0/modules/test/mod_autoindex.c
  
  Index: mod_autoindex.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/test/mod_autoindex.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mod_autoindex.c	2000/12/17 03:35:38	1.3
  +++ mod_autoindex.c	2001/01/05 19:40:04	1.4
  @@ -1622,7 +1622,7 @@
        */
       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.92      +1 -1      httpd-2.0/server/config.c
  
  Index: config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/config.c,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- config.c	2001/01/02 17:41:38	1.91
  +++ config.c	2001/01/05 19:40:05	1.92
  @@ -1389,7 +1389,7 @@
   	}
   	candidates = apr_make_array(p, 1, sizeof(fnames));
           while (apr_readdir(dirp) == APR_SUCCESS) {
  -            char *d_name;
  +            const char *d_name;
   	    apr_get_dir_filename(&d_name, dirp);
   	    /* strip out '.' and '..' */
   	    if (strcmp(d_name, ".") &&
  
  
  
  1.21      +1 -1      apr/file_io/os2/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/dir.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- dir.c	2000/12/17 03:35:40	1.20
  +++ dir.c	2001/01/05 19:40:05	1.21
  @@ -218,7 +218,7 @@
   
   
   
  -apr_status_t apr_get_dir_filename(char **new, apr_dir_t *thedir)
  +apr_status_t apr_get_dir_filename(const char **new, apr_dir_t *thedir)
   {
       if (thedir->validentry) {
           *new = thedir->entry.achName;
  
  
  
  1.42      +2 -2      apr/file_io/unix/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/dir.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- dir.c	2000/12/17 03:35:40	1.41
  +++ dir.c	2001/01/05 19:40:05	1.42
  @@ -240,14 +240,14 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_get_dir_filename(char **new, apr_dir_t *thedir)
  +apr_status_t apr_get_dir_filename(const char **new, apr_dir_t *thedir)
   {
       /* Detect End-Of-File */
       if (thedir == NULL || thedir->entry == NULL) {
           *new = NULL;
           return APR_ENOENT;
       }
  -    (*new) = apr_pstrdup(thedir->cntxt, thedir->entry->d_name);
  +    (*new) = thedir->entry->d_name;
       return APR_SUCCESS;
   }
   
  
  
  
  1.41      +2 -2      apr/file_io/win32/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/dir.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- dir.c	2000/12/17 03:35:40	1.40
  +++ dir.c	2001/01/05 19:40:05	1.41
  @@ -320,7 +320,7 @@
       }
   }
   
  -apr_status_t apr_get_dir_filename(char **new, apr_dir_t *thedir)
  +apr_status_t apr_get_dir_filename(const char **new, apr_dir_t *thedir)
   {
   #if APR_HAS_UNICODE_FS
       apr_oslevel_e os_level;
  @@ -333,7 +333,7 @@
       }
       else
   #endif
  -        (*new) = apr_pstrdup(thedir->cntxt, thedir->n.entry->cFileName);
  +        (*new) = thedir->n.entry->cFileName;
       return APR_SUCCESS;
   }
   
  
  
  
  1.85      +1 -1      apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_io.h,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- apr_file_io.h	2001/01/05 18:45:26	1.84
  +++ apr_file_io.h	2001/01/05 19:40:05	1.85
  @@ -745,7 +745,7 @@
    * @param new_path the file name of the directory entry. 
    * @param thedir the currently open directory.
    */                        
  -apr_status_t apr_get_dir_filename(char **new_path, apr_dir_t *thedir);
  +apr_status_t apr_get_dir_filename(const char **new_path, apr_dir_t *thedir);
   
   /**
    * Return the data associated with the current file.
  
  
  
  1.22      +1 -1      apr/test/testfile.c
  
  Index: testfile.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testfile.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- testfile.c	2000/12/17 03:35:41	1.21
  +++ testfile.c	2001/01/05 19:40:06	1.22
  @@ -280,7 +280,7 @@
       apr_file_t *file = NULL;
       apr_size_t bytes;
       apr_filetype_e type;
  -    char *fname;
  +    const char *fname;
   
       fprintf(stdout, "Testing Directory functions.\n");