Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

shmemory.C

Go to the documentation of this file.
00001 #include <string.h>
00002 #include "bcipc.h"
00003 #include "shmemory.h"
00004 
00005 
00006 SharedMem::SharedMem(long size)
00007 {
00008         shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
00009         if(shmid < 0)
00010                 perror("SharedMem::SharedMem");
00011         else
00012         {
00013                 data = (char*)shmat(shmid, 0, 0);
00014                 shmctl(shmid, IPC_RMID, 0);
00015         }
00016         this->size = size;
00017         client = 0;
00018 }
00019 
00020 SharedMem::SharedMem(int id, long size)
00021 {
00022         this->shmid = id;
00023 
00024         data = (char*)shmat(shmid, 0, 0);
00025         this->size = size;
00026         client = 1;
00027 }
00028 
00029 SharedMem::~SharedMem()
00030 {
00031         shmdt(data);
00032         data = 0;
00033         size = 0;
00034         shmid = 0;
00035 }
00036 
00037 int SharedMem::get_id()
00038 {
00039         return shmid;
00040 }
00041 
00042 long SharedMem::get_size()
00043 {
00044         return size;
00045 }
00046 

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4