libgit2

git_buf

Version:

A data buffer for exporting data from libgit2

Sometimes libgit2 wants to return an allocated data buffer to the caller and have the caller take responsibility for freeing that memory. To make ownership clear in these cases, libgit2 uses git_buf to return this data. Callers should use git_buf_dispose() to release the memory when they are done.

A git_buf contains a pointer to a NUL-terminated C string, and the length of the string (not including the NUL terminator).

Signature

typedef struct git_buf { char *ptr size_t reserved size_t size };

Members

char *
ptr

The buffer contents. ptr points to the start of the buffer being returned. The buffer's length (in bytes) is specified by the size member of the structure, and contains a NUL terminator at position (size + 1).

size_t
reserved

This field is reserved and unused.

size_t
size

The length (in bytes) of the buffer pointed to by ptr, not including a NUL terminator.

Parameter To

Versions