ap_slotmem_t *res;
ap_slotmem_t *next = globallistmem;
const char *fname;
+ apr_shm_t *shm;
apr_status_t rv;
if (gpool == NULL)
}
/* first try to attach to existing shared memory */
- res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
if (name && name[0] != ':') {
- rv = apr_shm_attach((apr_shm_t **)&res->shm, fname, gpool);
+ rv = apr_shm_attach(&shm, fname, gpool);
}
else {
rv = APR_EINVAL;
}
if (rv == APR_SUCCESS) {
/* check size */
- if (apr_shm_size_get((apr_shm_t *)res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
- apr_shm_detach((apr_shm_t *)res->shm);
- res->shm = NULL;
+ if (apr_shm_size_get(shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
+ apr_shm_detach(shm);
return APR_EINVAL;
}
- ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
+ ptr = apr_shm_baseaddr_get(shm);
memcpy(&desc, ptr, sizeof(desc));
if (desc.item_size != item_size || desc.item_num != item_num) {
- apr_shm_detach((apr_shm_t *)res->shm);
- res->shm = NULL;
+ apr_shm_detach(shm);
return APR_EINVAL;
}
ptr = ptr + sizeof(desc);
else {
if (name && name[0] != ':') {
apr_shm_remove(fname, gpool);
- rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, gpool);
+ rv = apr_shm_create(&shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, gpool);
}
else {
- rv = apr_shm_create((apr_shm_t **)&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, gpool);
+ rv = apr_shm_create(&shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, gpool);
}
if (rv != APR_SUCCESS) {
return rv;
}
- ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
+ ptr = apr_shm_baseaddr_get(shm);
desc.item_size = item_size;
desc.item_num = item_num;
memcpy(ptr, &desc, sizeof(desc));
}
/* For the chained slotmem stuff */
+ res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
res->name = apr_pstrdup(gpool, fname);
+ res->shm = shm;
res->base = ptr;
res->size = item_size;
res->num = item_num;
ap_slotmem_t *next = globallistmem;
struct sharedslotdesc desc;
const char *fname;
+ apr_shm_t *shm;
apr_status_t rv;
if (gpool == NULL) {
}
/* first try to attach to existing shared memory */
- res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
- rv = apr_shm_attach((apr_shm_t **)&res->shm, fname, gpool);
+ rv = apr_shm_attach(&shm, fname, gpool);
if (rv != APR_SUCCESS) {
return rv;
}
/* Read the description of the slotmem */
- ptr = apr_shm_baseaddr_get((apr_shm_t *)res->shm);
+ ptr = apr_shm_baseaddr_get(shm);
memcpy(&desc, ptr, sizeof(desc));
ptr = ptr + sizeof(desc);
/* For the chained slotmem stuff */
+ res = (ap_slotmem_t *) apr_pcalloc(gpool, sizeof(ap_slotmem_t));
res->name = apr_pstrdup(gpool, fname);
+ res->shm = shm;
res->base = ptr;
res->size = desc.item_size;
res->num = desc.item_num;