aboutsummaryrefslogtreecommitdiff
path: root/shmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'shmem.c')
-rw-r--r--shmem.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/shmem.c b/shmem.c
index f84cb60..72faa7d 100644
--- a/shmem.c
+++ b/shmem.c
@@ -208,8 +208,9 @@ void shmem_allocate(t_shmem *x, t_float fId, t_float fSize)
error("id should be > 0"); // shmid 0 doesn't seem to work
return;
}
-
+
x->segment_size = (int) fSize;
+ int size = sizeof(t_float)*x->segment_size;
#ifdef _WIN32
if ( x->share_memory ) UnmapViewOfFile( x->share_memory );
if ( x->m_MapFile ) CloseHandle( x->m_MapFile );
@@ -220,8 +221,8 @@ void shmem_allocate(t_shmem *x, t_float fId, t_float fSize)
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security
PAGE_READWRITE, // read/write access
- (x->segment_size & 0xFFFFFFFF00000000) >> 32, // maximum object size (high-order DWORD)
- x->segment_size & 0xFFFFFFFF, // maximum object size (low-order DWORD)
+ (size & 0xFFFFFFFF00000000) >> 32, // maximum object size (high-order DWORD)
+ size & 0xFFFFFFFF, // maximum object size (low-order DWORD)
x->m_fileMappingName); // name of mapping object
if (x->m_MapFile == NULL)
@@ -235,7 +236,7 @@ void shmem_allocate(t_shmem *x, t_float fId, t_float fSize)
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
- sizeof(t_float)*x->segment_size);
+ size);
if ( !x->share_memory ){
error("Could not get a view of file %s - error %ld",x->m_fileMappingName, GetLastError());
@@ -252,15 +253,15 @@ void shmem_allocate(t_shmem *x, t_float fId, t_float fSize)
shmdt (x->share_memory);
x->share_memory=NULL;
}
- if (x->segment_id != -1) {
+ if (x->segment_id != -1) {
shmctl (x->segment_id, IPC_RMID, 0);
x->segment_id = -1;
}
x->segment_id = shmget (id, sizeof(t_float)*x->segment_size,
IPC_CREAT | S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH); // AV it should safer to use ftok() to generate an id
-
- if(x->segment_id != -1) { // 0 could be a valid value, -1 means error
+
+ if(x->segment_id != -1) { // 0 could be a valid value, -1 means error
x->share_memory = (t_float*) shmat (x->segment_id, 0, 0);
// post("shmem memory attached at address %p\n", x->share_memory);