*new = next;
return APR_SUCCESS;
}
- if (next->next)
+ if (!next->next)
break;
next = next->next;
}
res->base = apr_pcalloc(globalpool, item_size * item_num);
if (!res->base)
return APR_ENOSHMAVAIL;
- memset(res->base, 0, item_size * item_num);
/* For the chained slotmem stuff */
res->name = apr_pstrdup(globalpool, fname);
static apr_status_t ap_slotmem_mem(ap_slotmem_t *score, int id, void**mem)
{
- void *ptr = score->base + score->size * id;
+ void *ptr;
if (!score)
return APR_ENOSHMAVAIL;
if (id<0 || id>score->num)
return APR_ENOSHMAVAIL;
+ ptr = score->base + score->size * id;
if (!ptr)
return APR_ENOSHMAVAIL;
*mem = ptr;
res->size = item_size;
res->num = item_num;
*new = res;
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ap_slotmem_create: score %d", score);
-
return APR_SUCCESS;
}
static apr_status_t ap_slotmem_mem(ap_slotmem_t *score, int id, void**mem)
if (!ptr)
return APR_ENOSHMAVAIL;
*mem = ptr;
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
- "ap_slotmem_mem: score %d", score);
return APR_SUCCESS;
}
*new = next;
return APR_SUCCESS;
}
- if (next->next)
+ if (!next->next)
break;
next = next->next;
}
static apr_status_t ap_slotmem_mem(ap_slotmem_t *score, int id, void**mem)
{
- void *ptr = score->base + score->size * id;
+ void *ptr;
if (!score)
return APR_ENOSHMAVAIL;
if (id<0 || id>score->num)
return APR_ENOSHMAVAIL;
- if (apr_shm_size_get(score->shm) != score->size * score->num)
- return APR_ENOSHMAVAIL;
+ ptr = score->base + score->size * id;
if (!ptr)
return APR_ENOSHMAVAIL;
*mem = ptr;
/* make sure the shared memory is cleaned */
static int initialize_cleanup(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
{
- ap_slotmem_t *next = globallistmem;
- while (next) {
- next = next->next;
- }
apr_pool_cleanup_register(p, &globallistmem, cleanup_slotmem, apr_pool_cleanup_null);
return OK;
}