const char *tmpname;
tmpname = apr_pstrcat(pool, "logs/", &slotmemname[1], NULL);
fname = ap_server_root_relative(pool, tmpname);
- }
- else
+ }
+ else {
fname = slotmemname;
+ }
storename = apr_pstrcat(pool, fname , ".slotmem", NULL);
return storename;
}
if (apr_file_info_get(&fi, APR_FINFO_SIZE, fp) == APR_SUCCESS) {
if (fi.size == nbytes) {
apr_file_read(fp, ptr, &nbytes);
- } else {
+ }
+ else {
apr_file_close(fp);
apr_file_remove(storename, pool);
return;
int i;
void *ptr;
- if (!mem)
+ if (!mem) {
return APR_ENOSHMAVAIL;
+ }
ptr = mem->base;
for (i = 0; i < mem->num; i++) {
if (globalpool == NULL)
return APR_ENOSHMAVAIL;
if (name) {
- if (name[0] == ':')
+ if (name[0] == ':') {
fname = name;
- else
+ }
+ else {
fname = ap_server_root_relative(pool, name);
+ }
/* first try to attach to existing slotmem */
if (next) {
*new = next;
return APR_SUCCESS;
}
- if (!next->next)
+ if (!next->next) {
break;
+ }
next = next->next;
}
}
- } else
+ }
+ else {
fname = "anonymous";
+ }
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
- if (name && name[0] != ':')
+ if (name && name[0] != ':') {
rv = apr_shm_attach(&res->shm, fname, globalpool);
- else
+ }
+ else {
rv = APR_EINVAL;
+ }
if (rv == APR_SUCCESS) {
/* check size */
if (apr_shm_size_get(res->shm) != item_size * item_num + sizeof(struct sharedslotdesc)) {
return APR_EINVAL;
}
ptr = ptr + sizeof(desc);
- } else {
+ }
+ else {
if (name && name[0] != ':') {
apr_shm_remove(fname, globalpool);
rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), fname, globalpool);
- } else {
+ }
+ else {
rv = apr_shm_create(&res->shm, item_size * item_num + sizeof(struct sharedslotdesc), NULL, globalpool);
}
if (rv != APR_SUCCESS) {
res->num = item_num;
res->globalpool = globalpool;
res->next = NULL;
- if (globallistmem==NULL)
+ if (globallistmem==NULL) {
globallistmem = res;
- else
+ }
+ else {
next->next = res;
+ }
*new = res;
return APR_SUCCESS;
const char *fname;
apr_status_t rv;
- if (globalpool == NULL)
+ if (globalpool == NULL) {
return APR_ENOSHMAVAIL;
+ }
if (name) {
- if (name[0] == ':')
+ if (name[0] == ':') {
fname = name;
- else
+ }
+ else {
fname = ap_server_root_relative(pool, name);
- } else
+ }
+ }
+ else {
return APR_ENOSHMAVAIL;
+ }
/* first try to attach to existing slotmem */
if (next) {
/* first try to attach to existing shared memory */
res = (ap_slotmem_t *) apr_pcalloc(globalpool, sizeof(ap_slotmem_t));
rv = apr_shm_attach(&res->shm, fname, globalpool);
- if (rv != APR_SUCCESS)
+ if (rv != APR_SUCCESS) {
return rv;
+ }
/* Read the description of the slotmem */
ptr = apr_shm_baseaddr_get(res->shm);
res->num = desc.item_num;
res->globalpool = globalpool;
res->next = NULL;
- if (globallistmem==NULL)
+ if (globallistmem==NULL) {
globallistmem = res;
- else
+ }
+ else {
next->next = res;
+ }
*new = res;
*item_size = desc.item_size;
void *ptr;
- if (!score)
+ if (!score) {
return APR_ENOSHMAVAIL;
- if (id<0 || id>score->num)
+ }
+ if (id<0 || id>score->num) {
return APR_ENOSHMAVAIL;
+ }
ptr = score->base + score->size * id;
- if (!ptr)
+ if (!ptr) {
return APR_ENOSHMAVAIL;
+ }
ptr = score->base + score->size * id;
*mem = ptr;
return APR_SUCCESS;