sharedmem.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 #ifndef WIN32
00004 #include<sys/ipc.h>
00005 #include<sys/shm.h>
00006 #endif
00007 #include <stdlib.h>
00008 
00009 #include "Linux4Win.h"
00010 
00011 unsigned char *InitSharedMem(int key, int size)
00012 {
00013   shm_key_t shmid;
00014   unsigned char *p;
00015 
00016   if ((shmid = shmget(key, size, IPC_CREAT | 0666)) == EOF){
00017     fprintf(stderr, "ShmGet Error\n");
00018     exit(0);
00019   }
00020   if ((p = (unsigned char*)shmat(shmid, 0, 0)) == (void*)(-1)) {
00021     fprintf(stderr, "ShmAt Error\n");
00022     exit(0);
00023   }
00024   memset(p, 0, size);
00025   return p;
00026 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


RS003
Author(s):
autogenerated on Thu Jun 27 2013 14:58:49