git_allocator

An instance for a custom memory allocator

Setting the pointers of this structure allows the developer to implement custom memory allocators. The global memory allocator can be set by using "git_libgit2_opt_t.GIT_OPT_SET_ALLOCATOR" with the git_libgit2_opts function. Keep in mind that all fields need to be set to a proper function.

Members

Variables

gcalloc
void* function(size_t nelem, size_t elsize, const(char)* file, int line) gcalloc;

Allocate memory for an array of nelem elements, where each element has a size of elsize. Returned memory shall be initialized to all-zeroes

gfree
void function(void* ptr_) gfree;

This function shall free the memory pointed to by ptr_. In case ptr_ is NULL, this shall be a no-op.

gmalloc
void* function(size_t n, const(char)* file, int line) gmalloc;

Allocate n bytes of memory

gmallocarray
void* function(size_t nelem, size_t elsize, const(char)* file, int line) gmallocarray;

This function shall allocate a new array of nelem elements, where each element has a size of elsize bytes.

grealloc
void* function(void* ptr_, size_t size, const(char)* file, int line) grealloc;

This function shall deallocate the old object ptr_ and return a pointer to a new object that has the size specified by size. In case ptr_ is NULL, a new array shall be allocated.

greallocarray
void* function(void* ptr_, size_t nelem, size_t elsize, const(char)* file, int line) greallocarray;

This function shall be equivalent to grealloc, but allocating neleme * elsize bytes.

gstrdup
char* function(const(char)* str, const(char)* file, int line) gstrdup;

Allocate memory for the string str and duplicate its contents.

gstrndup
char* function(const(char)* str, size_t n, const(char)* file, int line) gstrndup;

Equivalent to the gstrdup function, but only duplicating at most n + 1 bytes

gsubstrdup
char* function(const(char)* str, size_t n, const(char)* file, int line) gsubstrdup;

Equivalent to gstrndup, but will always duplicate exactly n bytes of str. Thus, out of bounds reads at str may happen.

Meta