summaryrefslogtreecommitdiff
path: root/shmem/win32
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2002-01-09 01:47:04 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2002-01-09 01:47:04 +0000
commit0e13ed5aac7acca3c9190d02d43be0531f244919 (patch)
tree3d028a84c8b1c2d5c5fe19e3151699c349f7aeea /shmem/win32
parent1d8fac3d4a78318dd2e1b882d15cb4944b21a788 (diff)
downloadapr-0e13ed5aac7acca3c9190d02d43be0531f244919.tar.gz
Some modest improvements pointed out by Aaron.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem/win32')
-rw-r--r--shmem/win32/shm.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/shmem/win32/shm.c b/shmem/win32/shm.c
index cd8910d4a..29408194f 100644
--- a/shmem/win32/shm.c
+++ b/shmem/win32/shm.c
@@ -59,14 +59,17 @@
#include "fileio.h"
typedef struct memblock_t {
+ apr_size_t size;
apr_size_t length;
} memblock_t;
struct apr_shm_t {
apr_pool_t *pool;
- memblock_t *mem;
- apr_size_t size;
- HANDLE hMap;
+ memblock_t *memblk;
+ void *usrmem;
+ apr_size_t size;
+ apr_size_t length;
+ HANDLE hMap;
};
static apr_status_t shm_cleanup(void* shm)
@@ -74,7 +77,7 @@ static apr_status_t shm_cleanup(void* shm)
apr_status_t rv = APR_SUCCESS;
apr_shm_t *m = shm;
- if (UnmapViewOfFile(m->mem)) {
+ if (UnmapViewOfFile(m->memblk)) {
rv = apr_get_os_error();
}
if (CloseHandle(m->hMap)) {
@@ -175,10 +178,13 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
*m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
(*m)->pool = pool;
(*m)->hMap = hMap;
- (*m)->mem = base;
+ (*m)->memblk = base;
+ (*m)->usrmem = (char*)base + sizeof(memblock_t);
(*m)->size = size;
+ (*m)->length = reqsize;
- (*m)->mem->length = reqsize;
+ (*m)->memblk->length = reqsize;
+ (*m)->memblk->size = size;
apr_pool_cleanup_register((*m)->pool, *m,
shm_cleanup, apr_pool_cleanup_null);
@@ -232,9 +238,11 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
*m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
(*m)->pool = pool;
(*m)->hMap = hMap;
- (*m)->mem = base;
+ (*m)->memblk = base;
+ (*m)->usrmem = (char*)base + sizeof(memblock_t);
/* Real (*m)->mem->size could be recovered with VirtualQuery */
- (*m)->size = (*m)->mem->length;
+ (*m)->size = (*m)->memblk->size;
+ (*m)->length = (*m)->memblk->length;
apr_pool_cleanup_register((*m)->pool, *m,
shm_cleanup, apr_pool_cleanup_null);
@@ -250,10 +258,10 @@ APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
{
- return (char*)m->mem + sizeof(memblock_t);
+ return m->usrmem;
}
APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
{
- return m->mem->length - sizeof(memblock_t);
+ return m->length;
}