File: newsegment.cc

package info (click to toggle)
bobcat 6.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,960 kB
  • sloc: cpp: 18,954; fortran: 5,617; makefile: 2,787; sh: 659; perl: 401; ansic: 26
file content (18 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "sharedsegment.ih"

int SharedSegment::newSegment(size_t requestedSize, size_t access)
{
    int id = shmget(IPC_PRIVATE, requestedSize, access);

    if (id == -1)                           // no block available
        throw Exception{} << "Cannot create a shared segment";

    size_t actualSize = size(id);

    if (actualSize != requestedSize)
        throw Exception{} << "Incorrect size (" << actualSize <<
                            ", should be: " << requestedSize <<
                            ") of shared segment";

    return id;
}