You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2024/06/26 15:48:53 UTC

svn commit: r1918670 - /apr/apr/trunk/tables/apr_tables.c

Author: ylavic
Date: Wed Jun 26 15:48:53 2024
New Revision: 1918670

URL: http://svn.apache.org/viewvc?rev=1918670&view=rev
Log:
apr_table: Use APR_TABLE_POOL_DEBUG rather than general APR_POOL_DEBUG

Entries need not necessarily be allocated on the table's pool or an ancestor
to have the correct lifetime, the pool they are allocated on just shouldn't
be destroyed before the table.

Don't prevent users that know what they are doing with apr_tables to enable
APR_POOL_DEBUG for the rest of their code, while APR_TABLE_POOL_DEBUG can
be used to enable the apr_tables specific lifetime/ancestor checks now.


Modified:
    apr/apr/trunk/tables/apr_tables.c

Modified: apr/apr/trunk/tables/apr_tables.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_tables.c?rev=1918670&r1=1918669&r2=1918670&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_tables.c (original)
+++ apr/apr/trunk/tables/apr_tables.c Wed Jun 26 15:48:53 2024
@@ -38,7 +38,11 @@
 #include <strings.h>
 #endif
 
-#if (APR_POOL_DEBUG || defined(MAKE_TABLE_PROFILE)) && APR_HAVE_STDIO_H
+#ifndef APR_TABLE_POOL_DEBUG
+#define APR_TABLE_POOL_DEBUG 0
+#endif
+
+#if (APR_TABLE_POOL_DEBUG || defined(MAKE_TABLE_PROFILE)) && APR_HAVE_STDIO_H
 #include <stdio.h>
 #endif
 
@@ -413,7 +417,7 @@ APR_DECLARE(apr_table_t *) apr_table_cop
 {
     apr_table_t *new = apr_palloc(p, sizeof(apr_table_t));
 
-#if APR_POOL_DEBUG
+#if APR_TABLE_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
      */
@@ -740,7 +744,7 @@ APR_DECLARE(void) apr_table_mergen(apr_t
     apr_uint32_t checksum;
     int hash;
 
-#if APR_POOL_DEBUG
+#if APR_TABLE_POOL_DEBUG
     {
 	apr_pool_t *pool;
 	pool = apr_pool_find(key);
@@ -814,7 +818,7 @@ APR_DECLARE(void) apr_table_addn(apr_tab
     apr_uint32_t checksum;
     int hash;
 
-#if APR_POOL_DEBUG
+#if APR_TABLE_POOL_DEBUG
     {
 	if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) {
 	    fprintf(stderr, "apr_table_addn: key not in ancestor pool of t\n");
@@ -846,7 +850,7 @@ APR_DECLARE(apr_table_t *) apr_table_ove
 {
     apr_table_t *res;
 
-#if APR_POOL_DEBUG
+#if APR_TABLE_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
@@ -1237,7 +1241,7 @@ APR_DECLARE(void) apr_table_overlap(apr_
         return;
     }
 
-#if APR_POOL_DEBUG
+#if APR_TABLE_POOL_DEBUG
     /* Since the keys and values are not copied, it's required that
      * b->a.pool has a lifetime at least as long as a->a.pool. */
     if (!apr_pool_is_ancestor(b->a.pool, a->a.pool)) {