Content#

Functions#

struct OmniClientContent omniClientAllocContent(size_t size)

Allocate a content buffer with the specified size.

struct OmniClientContent omniClientCopyContent(struct OmniClientContent const *content)

Copy a content buffer.

void omniClientFreeContent(struct OmniClientContent *content)

Free an allocated content buffer.

struct OmniClientContent omniClientMoveContent(struct OmniClientContent *content)

Attempt to take ownership of a content buffer.

struct OmniClientContent omniClientReferenceContent(void *buffer, size_t size)

Reference an existing content buffer.

Structs#

OmniClientContent

Content buffer for file operations.

Functions#

struct OmniClientContent omniClientAllocContent(size_t size)#

Allocate a content buffer with the specified size.

You can fill in the returned buffer then pass it to the various client library functions such as omniClientWriteFile and omniClientSendMessage which will then take ownership of the buffer and free it when they are finished with it.

Parameters:

size – The size of the buffer to allocate in bytes

Returns:

A content buffer with allocated memory

struct OmniClientContent omniClientCopyContent(
struct OmniClientContent const *content,
)#

Copy a content buffer.

You are required to call omniClientFreeContent when you are finished with it.

Parameters:

content – The content buffer to copy

Returns:

A new content buffer with copied data

void omniClientFreeContent(struct OmniClientContent *content)#

Free an allocated content buffer.

It’s safe to call this with a content buffer that was referenced with omniClientReferenceContent (though the content will obviously not actually be freed). This function also clears the structure (setting size to 0, buffer to nullptr, etc)

Parameters:

content – The content buffer to free

struct OmniClientContent omniClientMoveContent(
struct OmniClientContent *content,
)#

Attempt to take ownership of a content buffer.

When you receive a buffer through a callback, such as OmniClientReadFileCallback, you can take ownership of the buffer by calling this function. The library will not free the buffer, so you are required to call omniClientFreeContent when you are finished with it.

If it’s not possible to take ownership of the buffer (because it was referenced rather than allocated) then this will fall back to calling omniClientCopyContent

Parameters:

content – The content buffer to take ownership of

Returns:

A content buffer with ownership transferred, or a copy if ownership cannot be transferred

struct OmniClientContent omniClientReferenceContent(
void *buffer,
size_t size,
)#

Reference an existing content buffer.

The difference between calling omniClientAllocContent and this function is referencing a buffer prevents the library from taking ownership of the buffer. Therefore you must ensure the buffer exists at least until the library is finished using it.

Parameters:
  • buffer – The existing buffer to reference

  • size – The size of the buffer in bytes

Returns:

A content buffer that references the existing memory