l3.libnazgul/src/poolDataTabCreate.c

43 lines
974 B
C
Raw Normal View History

2004-02-25 10:32:41 +00:00
#include "libnazgul.h"
#include "ids.h"
void * msgPoolDataTabCreate(msgSpace * space){
int poolDataFd; // shm file descriptor
msgPoolData * poolDataTabAddr;
poolDataFd=shm_open(
space->poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE
);
if (poolDataFd == -1 ) {
NZG_ERROR("shm_open :create",space->poolDataTabId);
goto ERROR;
}
/* allocation de la bonne zone m<>moire pour le poolData */
if (ftruncate(poolDataFd, (space->poolNb)*sizeof(msgPoolData)) == -1){
NZG_ERROR("ftruncate",space->poolDataTabId);
goto ERROR;
}
close(poolDataFd);
poolDataTabAddr = msgPoolDataTabOpen(space);
if (poolDataTabAddr == NULL){
NZG_ERROR("msgPoolDataTabOpen : create",space->poolDataTabId);
goto ERROR;
}
/*mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 );
if( poolDataAddr == MAP_FAILED ) {
NZG_ERROR("mmap",poolDataTabId);
goto ERROR;
}*/
return poolDataTabAddr;
ERROR:
return NULL;
}