+struct mag_conn *mag_new_conn_ctx(apr_pool_t *pool)
+{
+ struct mag_conn *mc;
+
+ mc = apr_pcalloc(pool, sizeof(struct mag_conn));
+ apr_pool_create(&mc->pool, pool);
+ /* register the context in the memory pool, so it can be freed
+ * when the connection/request is terminated */
+ apr_pool_cleanup_register(mc->pool, (void *)mc,
+ mag_conn_destroy, apr_pool_cleanup_null);
+
+ return mc;
+}
+
+static void mag_conn_clear(struct mag_conn *mc)
+{
+ (void)mag_conn_destroy(mc);
+ apr_pool_t *temp;
+
+ apr_pool_clear(mc->pool);
+ temp = mc->pool;
+ memset(mc, 0, sizeof(struct mag_conn));
+ mc->pool = temp;
+}
+