apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: apr/tables apr_tables.c
Date Sat, 20 Jan 2001 11:34:32 GMT
gstein      01/01/20 03:34:32

  Modified:    include  apr_tables.h
               tables   apr_tables.c
  Log:
  yes, you *will* use a hash instead. any questions can be directed to Bubba.
  
  Revision  Changes    Path
  1.12      +0 -159    apr/include/apr_tables.h
  
  Index: apr_tables.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_tables.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -u -r1.11 -r1.12
  --- apr_tables.h	2001/01/18 20:07:22	1.11
  +++ apr_tables.h	2001/01/20 11:34:32	1.12
  @@ -80,7 +80,6 @@
    * published.
    */
   typedef struct apr_table_t apr_table_t;
  -typedef struct apr_btable_t apr_btable_t;
   typedef struct apr_array_header_t apr_array_header_t;
   
   /** An opaque array type */
  @@ -112,21 +111,6 @@
   #endif
   };
   
  -/** The opaque binary-content table type */
  -struct apr_btable_t {
  -    /* This has to be first to promote backwards compatibility with
  -     * older modules which cast a apr_table_t * to an apr_array_header_t *...
  -     * they should use the table_elts() function for most of the
  -     * cases they do this for.
  -     */
  -    /** The underlying array for the table */
  -    apr_array_header_t a;
  -#ifdef MAKE_TABLE_PROFILE
  -    /** Who created the array. */
  -    void *creator;
  -#endif
  -};
  -
   /**
    * The (opaque) structure for string-content tables.
    */
  @@ -143,11 +127,6 @@
   };
   
   /**
  - * The (opaque) structure for binary-content tables.
  - */
  -typedef struct apr_btable_entry_t apr_btable_entry_t;
  -
  -/**
    * A transparent type for items stored in binary-content tables, and
    * possibly elsewhere.
    */
  @@ -162,16 +141,6 @@
       void *data;
   } apr_item_t;
   
  -/** The type for each entry in a binary-content table */
  -struct apr_btable_entry_t {
  -    /** The key for the current table entry */
  -    char *key;          /* maybe NULL in future;
  -                         * check when iterating thru table_elts
  -                         */
  -    /** The value for the current table entry */
  -    apr_item_t *val;
  -};
  -
   /**
    * Get the elements from a table
    * @param t The table
  @@ -181,14 +150,6 @@
   #define apr_table_elts(t) ((apr_array_header_t *)(t))
   
   /**
  - * Get the elements from a binary table
  - * @param t The table
  - * @return An array containing the contents of the table
  - * @deffunc apr_array_header_t *apr_table_elts(apr_table_t *t)
  - */
  -#define apr_btable_elts(t) apr_table_elts(t)
  -
  -/**
    * Determine if the table is empty
    * @param t The table to check
    * @return True if empty, Falso otherwise
  @@ -196,13 +157,6 @@
    */
   #define apr_is_empty_table(t) (((t) == NULL) \
                                  || (((apr_array_header_t *)(t))->nelts == 0))
  -/**
  - * Determine if the binary table is empty
  - * @param t The table to check
  - * @return True if empty, Falso otherwise
  - * @deffunc int apr_is_empty_btable(apr_table_t *t)
  - */
  -#define apr_is_empty_btable(t) apr_is_empty_table(t)
   
   /**
    * Create an array
  @@ -301,15 +255,6 @@
   APR_DECLARE(apr_table_t *) apr_make_table(struct apr_pool_t *p, int nelts);
   
   /**
  - * Make a new table capable of storing binary data
  - * @param p The pool to allocate the pool out of
  - * @param nelts The number of elements in the initial table.
  - * @return The new table.
  - * @deffunc apr_table_t *apr_make_btable(apr_pool_t *p, int nelts)
  - */
  -APR_DECLARE(apr_btable_t *) apr_make_btable(struct apr_pool_t *p, int nelts);
  -
  -/**
    * Create a new table and copy another table into it
    * @param p The pool to allocate the new table out of
    * @param t The table to copy
  @@ -320,16 +265,6 @@
                                             const apr_table_t *t);
   
   /**
  - * Create a new binary table and copy another table into it
  - * @param p The pool to allocate the new table out of
  - * @param t The table to copy
  - * @return A copy of the table passed in
  - * @deffunc apr_table_t *apr_copy_btable(apr_pool_t *p, const apr_btable_t *t)
  - */
  -APR_DECLARE(apr_btable_t *) apr_copy_btable(struct apr_pool_t *p,
  -                                            const apr_btable_t *t);
  -
  -/**
    * Delete all of the elements from a table
    * @param t The table to clear
    * @deffunc void apr_clear_table(apr_table_t *t)
  @@ -337,13 +272,6 @@
   APR_DECLARE(void) apr_clear_table(apr_table_t *t);
   
   /**
  - * Delete all of the elements from a binary table
  - * @param t The table to clear
  - * @deffunc void apr_clear_btable(apr_btable_t *t)
  - */
  -APR_DECLARE(void) apr_clear_btable(apr_btable_t *t);
  -
  -/**
    * Get the value associated with a given key from the table.  After this call,
    * The data is still in the table
    * @param t The table to search for the key
  @@ -354,17 +282,6 @@
   APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key);
   
   /**
  - * Get the value associated with a given key from a binary table.  After this
  - * call, the data is still in the table.
  - * @param t The table to search for the key
  - * @param key The key to search for
  - * @return The value associated with the key
  - * @deffunc const apr_item_t *apr_btable_get(const apr_btable_t *t, const char *key)
  - */
  -APR_DECLARE(const apr_item_t *) apr_btable_get(const apr_btable_t *t,
  -                                               const char *key);
  -
  -/**
    * Add a key/value pair to a table, if another element already exists with the
    * same key, this will over-write the old data.
    * @param t The table to add the data to.
  @@ -378,20 +295,6 @@
                                   const char *val);
   
   /**
  - * Add a key/value pair to a binary table if another element already exists 
  - * with the same key, this will over-write the old data.
  - * @param t The table to add the data to.
  - * @param key The key fo use
  - * @param size The size of the data to add
  - * @param val The value to add
  - * @tip When adding data, this function makes a copy of both the key and the
  - *      value.
  - * @deffunc void apr_btable_set(apr_btable_t *t, const char *key, size_t size, const void
*val)
  - */
  -APR_DECLARE(void) apr_btable_set(apr_btable_t *t, const char *key,
  -                                 size_t size, const void *val);
  -
  -/**
    * Add a key/value pair to a table, if another element already exists with the
    * same key, this will over-write the old data.
    * @param t The table to add the data to.
  @@ -404,20 +307,6 @@
    */
   APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key,
                                    const char *val);
  -/**
  - * Add a key/value pair to a binary table if another element already exists 
  - * with the same key, this will over-write the old data.
  - * @param t The table to add the data to.
  - * @param key The key fo use
  - * @param size The size of the data to add
  - * @param val The value to add
  - * @tip When adding data, this function does not make a copy of the key or the
  - *      value, so care should be taken to ensure that the values will not 
  - *      change after they have been added..
  - * @deffunc void apr_btable_setn(apr_btable_t *t, const char *key, size_t size, const void
*val)
  - */
  -APR_DECLARE(void) apr_btable_setn(apr_btable_t *t, const char *key,
  -				 size_t size, const void *val);
   
   /**
    * Remove data from the table
  @@ -428,14 +317,6 @@
   APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key);
   
   /**
  - * Remove data from a binary table
  - * @param t The table to remove data from
  - * @param key The key of the data being removed
  - * @deffunc void apr_btable_unset(apr_btable_t *t, const char *key)
  - */
  -APR_DECLARE(void) apr_btable_unset(apr_btable_t *t, const char *key);
  -
  -/**
    * Add data to a table by merging the value with data that has already been 
    * stored
    * @param t The table to search for the data
  @@ -473,20 +354,6 @@
                                   const char *val);
   
   /**
  - * Add data to a binary table, regardless of whether there is another element 
  - * with the same key.
  - * @param t The table to add to
  - * @param key The key to use
  - * @param size The size of the value to add
  - * @param val The value to add.
  - * @tip When adding data, this function makes a copy of both the key and the
  - *      value.
  - * @deffunc void apr_btable_add(apr_btable_t *t, const char *key, size_t size, const char
*val)
  - */
  -APR_DECLARE(void) apr_btable_add(apr_btable_t *t, const char *key,
  -                                 size_t size, const void *val);
  -
  -/**
    * Add data to a table, regardless of whether there is another element with the
    * same key.
    * @param t The table to add to
  @@ -501,21 +368,6 @@
                                    const char *val);
   
   /**
  - * Add data to a binary table, regardless of whether there is another element 
  - * with the same key.
  - * @param t The table to add to
  - * @param key The key to use
  - * @param size The size of the value to add
  - * @param val The value to add.
  - * @tip When adding data, this function does not make a copy of the key or the
  - *      value, so care should be taken to ensure that the values will not 
  - *      change after they have been added..
  - * @deffunc void apr_btable_addn(apr_btable_t *t, const char *key, size_t size, const char
*val)
  - */
  -APR_DECLARE(void) apr_btable_addn(apr_btable_t *t, const char *key,
  -                                  size_t size, const void *val);
  -
  -/**
    * Merge two tables into one new table
    * @param p The pool to use for the new table
    * @param overlay The first table to put in the new table
  @@ -526,17 +378,6 @@
   APR_DECLARE(apr_table_t *) apr_overlay_tables(struct apr_pool_t *p,
                                                 const apr_table_t *overlay,
                                                 const apr_table_t *base);
  -/**
  - * Merge two binary tables into one new table
  - * @param p The pool to use for the new table
  - * @param overlay The first table to put in the new table
  - * @param base The table to add at the end of the new table
  - * @return A new table containing all of the data from the two passed in
  - * @deffunc apr_btable_t *apr_overlay_tables(apr_pool_t *p, const apr_btable_t *overlay,
const apr_btable_t *base);
  - */
  -APR_DECLARE(apr_btable_t *) apr_overlay_btables(struct apr_pool_t *p,
  -                                                const apr_btable_t *overlay,
  -                                                const apr_btable_t *base);
   
   /** 
    * Iterate over a table running the provided function once for every
  
  
  
  1.10      +0 -247    apr/tables/apr_tables.c
  
  Index: apr_tables.c
  ===================================================================
  RCS file: /home/cvs/apr/tables/apr_tables.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -u -r1.9 -r1.10
  --- apr_tables.c	2000/12/22 16:54:57	1.9
  +++ apr_tables.c	2001/01/20 11:34:32	1.10
  @@ -304,17 +304,6 @@
       return t;
   }
   
  -APR_DECLARE(apr_btable_t *) apr_make_btable(apr_pool_t *p, int nelts)
  -{
  -    apr_btable_t *t = apr_palloc(p, sizeof(apr_btable_t));
  -
  -    make_array_core(&t->a, p, nelts, sizeof(apr_btable_entry_t));
  -#ifdef MAKE_TABLE_PROFILE
  -    t->creator = __builtin_return_address(0);
  -#endif
  -    return t;
  -}
  -
   APR_DECLARE(apr_table_t *) apr_copy_table(apr_pool_t *p, const apr_table_t *t)
   {
       apr_table_t *new = apr_palloc(p, sizeof(apr_table_t));
  @@ -334,36 +323,11 @@
       return new;
   }
   
  -APR_DECLARE(apr_btable_t *) apr_copy_btable(apr_pool_t *p,
  -					   const apr_btable_t *t)
  -{
  -    apr_btable_t *new = apr_palloc(p, sizeof(apr_btable_entry_t));
  -
  -#ifdef POOL_DEBUG
  -    /* we don't copy keys and values, so it's necessary that t->a.pool
  -     * have a life span at least as long as p
  -     */
  -    if (!apr_pool_is_ancestor(t->a.cont, p)) {
  -	fprintf(stderr, "copy_btable: t's pool is not an ancestor of p\n");
  -	abort();
  -    }
  -#endif
  -    make_array_core(&new->a, p, t->a.nalloc, sizeof(apr_btable_entry_t));
  -    memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(apr_btable_entry_t));
  -    new->a.nelts = t->a.nelts;
  -    return new;
  -}
  -
   APR_DECLARE(void) apr_clear_table(apr_table_t *t)
   {
       t->a.nelts = 0;
   }
   
  -APR_DECLARE(void) apr_clear_btable(apr_btable_t *t)
  -{
  -    t->a.nelts = 0;
  -}
  -
   APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key)
   {
       apr_table_entry_t *elts = (apr_table_entry_t *) t->a.elts;
  @@ -382,25 +346,6 @@
       return NULL;
   }
   
  -APR_DECLARE(const apr_item_t *) apr_btable_get(const apr_btable_t *t,
  -					      const char *key)
  -{
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -    int i;
  -
  -    if (key == NULL) {
  -	return NULL;
  -    }
  -
  -    for (i = 0; i < t->a.nelts; ++i) {
  -	if (!strcasecmp(elts[i].key, key)) {
  -	    return elts[i].val;
  -	}
  -    }
  -
  -    return NULL;
  -}
  -
   APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key,
   			       const char *val)
   {
  @@ -435,46 +380,6 @@
       }
   }
   
  -APR_DECLARE(void) apr_btable_set(apr_btable_t *t, const char *key,
  -				size_t size, const void *val)
  -{
  -    register int i, j, k;
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -    apr_item_t *item;
  -    int done = 0;
  -
  -    item = apr_pcalloc(t->a.cont, sizeof(apr_item_t));
  -    item->size = size;
  -    item->data = apr_pcalloc(t->a.cont, size);
  -    memcpy(item->data, val, size);
  -
  -    for (i = 0; i < t->a.nelts; ) {
  -	if (!strcasecmp(elts[i].key, key)) {
  -	    if (!done) {
  -		elts[i].val = item;
  -		done = 1;
  -		++i;
  -	    }
  -	    else {		/* delete an extraneous element */
  -		for (j = i, k = i + 1; k < t->a.nelts; ++j, ++k) {
  -		    elts[j].key = elts[k].key;
  -		    elts[j].val = elts[k].val;
  -		}
  -		--t->a.nelts;
  -	    }
  -	}
  -	else {
  -	    ++i;
  -	}
  -    }
  -
  -    if (!done) {
  -	elts = (apr_btable_entry_t *) table_push((apr_btable_t *) t);
  -	elts->key = apr_pstrdup(t->a.cont, key);
  -	elts->val = item;
  -    }
  -}
  -
   APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key,
   				const char *val)
   {
  @@ -522,58 +427,6 @@
       }
   }
   
  -APR_DECLARE(void) apr_btable_setn(apr_btable_t *t, const char *key,
  -				 size_t size, const void *val)
  -{
  -    register int i, j, k;
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -    int done = 0;
  -    apr_item_t *item;
  -
  -#ifdef POOL_DEBUG
  -    {
  -	if (!apr_pool_is_ancestor(apr_find_pool(key), t->a.cont)) {
  -	    fprintf(stderr, "table_set: key not in ancestor pool of t\n");
  -	    abort();
  -	}
  -	if (!apr_pool_is_ancestor(apr_find_pool(val), t->a.cont)) {
  -	    fprintf(stderr, "table_set: val not in ancestor pool of t\n");
  -	    abort();
  -	}
  -    }
  -#endif
  -
  -    item = (apr_item_t *) apr_pcalloc(t->a.cont, size);
  -    item->size = size;
  -    item->data = (void *)val;
  -
  -    for (i = 0; i < t->a.nelts; ) {
  -	if (!strcasecmp(elts[i].key, key)) {
  -	    if (!done) {
  -		elts[i].val = item;
  -		done = 1;
  -		++i;
  -	    }
  -	    else {		/* delete an extraneous element */
  -		for (j = i, k = i + 1; k < t->a.nelts; ++j, ++k) {
  -		    elts[j].key = elts[k].key;
  -		    elts[j].val = elts[k].val;
  -		}
  -		--t->a.nelts;
  -	    }
  -	}
  -	else {
  -	    ++i;
  -	}
  -    }
  -
  -    if (!done) {
  -	elts = (apr_btable_entry_t *) table_push((apr_table_t *)t);
  -	elts->key = (char *)key;
  -	elts->val = item;
  -    }
  -}
  -
   APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key)
   {
       register int i, j, k;
  @@ -599,31 +452,6 @@
       }
   }
   
  -APR_DECLARE(void) apr_btable_unset(apr_btable_t *t, const char *key)
  -{
  -    register int i, j, k;
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -
  -    for (i = 0; i < t->a.nelts; ) {
  -	if (!strcasecmp(elts[i].key, key)) {
  -
  -	    /* found an element to skip over
  -	     * there are any number of ways to remove an element from
  -	     * a contiguous block of memory.  I've chosen one that
  -	     * doesn't do a memcpy/bcopy/array_delete, *shrug*...
  -	     */
  -	    for (j = i, k = i + 1; k < t->a.nelts; ++j, ++k) {
  -		elts[j].key = elts[k].key;
  -		elts[j].val = elts[k].val;
  -	    }
  -	    --t->a.nelts;
  -	}
  -	else {
  -	    ++i;
  -	}
  -    }
  -}
  -
   APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key,
   				 const char *val)
   {
  @@ -683,21 +511,6 @@
       elts->val = apr_pstrdup(t->a.cont, val);
   }
   
  -APR_DECLARE(void) apr_btable_add(apr_btable_t *t, const char *key,
  -				size_t size, const void *val)
  -{
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -    apr_item_t *item;
  -
  -    item = (apr_item_t *) apr_pcalloc(t->a.cont, sizeof(apr_item_t));
  -    item->size = size;
  -    item->data = apr_pcalloc(t->a.cont, size);
  -    memcpy(item->data, val, size);
  -    elts = (apr_btable_entry_t *) table_push((apr_btable_t *)t);
  -    elts->key = apr_pstrdup(t->a.cont, key);
  -    elts->val = item;
  -}
  -
   APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key,
   				const char *val)
   {
  @@ -721,34 +534,6 @@
       elts->val = (char *)val;
   }
   
  -APR_DECLARE(void) apr_btable_addn(apr_btable_t *t, const char *key,
  -				 size_t size, const void *val)
  -{
  -    apr_btable_entry_t *elts = (apr_btable_entry_t *) t->a.elts;
  -    apr_item_t *item;
  -
  -#ifdef POOL_DEBUG
  -    {
  -	if (!apr_pool_is_ancestor(apr_find_pool(key), t->a.cont)) {
  -	    fprintf(stderr, "table_set: key not in ancestor pool of t\n");
  -	    abort();
  -	}
  -	if (!apr_pool_is_ancestor(apr_find_pool(val), t->a.cont)) {
  -	    fprintf(stderr, "table_set: key not in ancestor pool of t\n");
  -	    abort();
  -	}
  -    }
  -#endif
  -
  -    item = (apr_item_t *) apr_pcalloc(t->a.cont, sizeof(apr_item_t));
  -    item->size = size;
  -    item->data = apr_pcalloc(t->a.cont, size);
  -    memcpy(item->data, val, size);
  -    elts = (apr_btable_entry_t *) table_push((apr_btable_t *)t);
  -    elts->key = (char *)key;
  -    elts->val = item;
  -}
  -
   APR_DECLARE(apr_table_t *) apr_overlay_tables(apr_pool_t *p,
   					     const apr_table_t *overlay,
   					     const apr_table_t *base)
  @@ -773,38 +558,6 @@
   #endif
   
       res = apr_palloc(p, sizeof(apr_table_t));
  -    /* behave like append_arrays */
  -    res->a.cont = p;
  -    copy_array_hdr_core(&res->a, &overlay->a);
  -    apr_array_cat(&res->a, &base->a);
  -
  -    return res;
  -}
  -
  -APR_DECLARE(apr_btable_t *) apr_overlay_btables(apr_pool_t *p,
  -					       const apr_btable_t *overlay,
  -					       const apr_btable_t *base)
  -{
  -    apr_btable_t *res;
  -
  -#ifdef POOL_DEBUG
  -    /* we don't copy keys and values, so it's necessary that
  -     * overlay->a.pool and base->a.pool have a life span at least
  -     * as long as p
  -     */
  -    if (!apr_pool_is_ancestor(overlay->a.cont, p)) {
  -	fprintf(stderr,
  -		"overlay_tables: overlay's pool is not an ancestor of p\n");
  -	abort();
  -    }
  -    if (!apr_pool_is_ancestor(base->a.cont, p)) {
  -	fprintf(stderr,
  -		"overlay_tables: base's pool is not an ancestor of p\n");
  -	abort();
  -    }
  -#endif
  -
  -    res = apr_palloc(p, sizeof(apr_btable_t));
       /* behave like append_arrays */
       res->a.cont = p;
       copy_array_hdr_core(&res->a, &overlay->a);
  
  
  

Mime
View raw message