Instrument Neutral Distributed Interface INDI 2.2.5
Classes | Macros | Typedefs | Functions
sharedblob.c File Reference
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  shared_buffer
 

Macros

#define _GNU_SOURCE
 
#define BLOB_SIZE_UNIT   0x100000
 

Typedefs

typedef struct shared_buffer shared_buffer
 

Functions

void * IDSharedBlobAlloc (size_t size)
 Allocate a buffer suitable for fast exchange over local links. Warning : the buffer will be sealed (readonly) once exchanged.
 
void * IDSharedBlobAttach (int fd, size_t size)
 
void IDSharedBlobFree (void *ptr)
 Free a buffer allocated using IDSharedBlobAlloc. Fall back to free for buffer that are not shared blob Must be used for IBLOB.data.
 
void IDSharedBlobDettach (void *ptr)
 Dettach a blob, but don't close its FD.
 
void * IDSharedBlobRealloc (void *ptr, size_t size)
 Adjust the size of a buffer obtained using IDSharedBlobAlloc.
 
int IDSharedBlobGetFd (void *ptr)
 Return the filedescriptor backing up the given shared buffer.
 
void IDSharedBlobSeal (void *ptr)
 Seal (make readonly) a buffer allocated using IDSharedBlobAlloc. This is automatic when IDNewBlob.
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

INDI Copyright (C) 2022 by Ludovic Pollet

This library is free software; you can redistribute it and / or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA

Definition at line 23 of file sharedblob.c.

◆ BLOB_SIZE_UNIT

#define BLOB_SIZE_UNIT   0x100000

Definition at line 45 of file sharedblob.c.

Typedef Documentation

◆ shared_buffer

typedef struct shared_buffer shared_buffer

Function Documentation

◆ IDSharedBlobAlloc()

void * IDSharedBlobAlloc ( size_t  size)

Allocate a buffer suitable for fast exchange over local links. Warning : the buffer will be sealed (readonly) once exchanged.

Parameters
size_tsize of the memory area to allocate

Definition at line 73 of file sharedblob.c.

◆ IDSharedBlobAttach()

void * IDSharedBlobAttach ( int  fd,
size_t  size 
)

Attach to a received shared buffer by ID The returned buffer cannot be realloced or sealed.

Returns
null on error + errno (invalid fd / system resources)

Definition at line 109 of file sharedblob.c.

◆ IDSharedBlobDettach()

void IDSharedBlobDettach ( void *  ptr)

Dettach a blob, but don't close its FD.

Definition at line 165 of file sharedblob.c.

◆ IDSharedBlobFree()

void IDSharedBlobFree ( void *  ptr)

Free a buffer allocated using IDSharedBlobAlloc. Fall back to free for buffer that are not shared blob Must be used for IBLOB.data.

Definition at line 139 of file sharedblob.c.

◆ IDSharedBlobGetFd()

int IDSharedBlobGetFd ( void *  ptr)

Return the filedescriptor backing up the given shared buffer.

Returns
the filedescriptor or -1 if not a shared buffer pointer

Definition at line 265 of file sharedblob.c.

◆ IDSharedBlobRealloc()

void * IDSharedBlobRealloc ( void *  ptr,
size_t  size 
)

Adjust the size of a buffer obtained using IDSharedBlobAlloc.

Parameters
size_tsize of the memory area to allocate

Definition at line 186 of file sharedblob.c.

◆ IDSharedBlobSeal()

void IDSharedBlobSeal ( void *  ptr)

Seal (make readonly) a buffer allocated using IDSharedBlobAlloc. This is automatic when IDNewBlob.

Parameters
size_tsize of the memory area to allocate

Definition at line 281 of file sharedblob.c.