httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Sun, 27 Jul 2003 14:40:52 GMT
nd          2003/07/27 07:40:52

  Modified:    modules/mappers mod_rewrite.c
  Log:
  cleanup lookup_map_dbmfile function.
  improve efficiency and readablity.
  
  Revision  Changes    Path
  1.185     +15 -15    httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.184
  retrieving revision 1.185
  diff -u -r1.184 -r1.185
  --- mod_rewrite.c	27 Jul 2003 13:49:15 -0000	1.184
  +++ mod_rewrite.c	27 Jul 2003 14:40:52 -0000	1.185
  @@ -1430,25 +1430,25 @@
       apr_dbm_t *dbmfp = NULL;
       apr_datum_t dbmkey;
       apr_datum_t dbmval;
  -    char *value = NULL;
  -    char buf[MAX_STRING_LEN];
  -    apr_status_t rv;
  +    char *value;
  +
  +    if (apr_dbm_open_ex(&dbmfp, dbmtype, file, APR_DBM_READONLY, APR_OS_DEFAULT, 
  +                        r->pool) != APR_SUCCESS) {
  +        return NULL;
  +    }
   
       dbmkey.dptr  = key;
       dbmkey.dsize = strlen(key);
  -    if ((rv = apr_dbm_open_ex(&dbmfp, dbmtype, file, APR_DBM_READONLY,
  -                              0 /* irrelevant when reading */,
  -                              r->pool)) == APR_SUCCESS) {
  -        rv = apr_dbm_fetch(dbmfp, dbmkey, &dbmval);
  -        if (rv == APR_SUCCESS && dbmval.dptr) {
  -            memcpy(buf, dbmval.dptr,
  -                   dbmval.dsize < sizeof(buf)-1 ?
  -                   dbmval.dsize : sizeof(buf)-1  );
  -            buf[dbmval.dsize] = '\0';
  -            value = apr_pstrdup(r->pool, buf);
  -        }
  -        apr_dbm_close(dbmfp);
  +
  +    if (apr_dbm_fetch(dbmfp, dbmkey, &dbmval) == APR_SUCCESS && dbmval.dptr)
{
  +        value = apr_pstrmemdup(r->pool, dbmval.dptr, dbmval.dsize);
       }
  +    else {
  +        value = NULL;
  +    }
  +
  +    apr_dbm_close(dbmfp);
  +
       return value;
   }
   
  
  
  

Mime
View raw message