On this page:
git_  buf_  contains_  nul
git_  buf_  free
git_  buf_  grow
git_  buf_  is_  binary
git_  buf_  set
8.12

5 Buffer🔗ℹ

 (require libgit2/include/buffer) package: libgit2

procedure

(git_buf_contains_nul buf)  boolean?

  buf : buf?
Check quickly if buffer contains a NUL byte

procedure

(git_buf_free buffer)  void?

  buffer : buf?
Free the memory referred to by the git_buf.

Note that this does not free the git_buf itself, just the memory pointed to by buffer->ptr. This will not free the memory if it looks like it was not allocated internally, but it will clear the buffer back to the empty state.

procedure

(git_buf_grow buffer target_size)  integer?

  buffer : buf?
  target_size : exact-positive-integer?
Resize the buffer allocation to make more space.

This will attempt to grow the buffer to accommodate the target size.

If the buffer refers to memory that was not allocated by libgit2 (i.e. the asize field is zero), then ptr will be replaced with a newly allocated block of data. Be careful so that memory allocated by the caller is not lost. As a special variant, if you pass target_size as 0 and the memory is not allocated by libgit2, this will allocate a new buffer of size size and copy the external data into it.

Currently, this will never shrink a buffer, only expand it.

If the allocation fails, this will return an error and the buffer will be marked as invalid for future operations, invaliding the contents.

procedure

(git_buf_is_binary buf)  boolean?

  buf : buf?
Check quickly if buffer looks like it contains binary data

procedure

(git_buf_set buffer data datalen)  integer?

  buffer : buf?
  data : bytes?
  datalen : exact-positive-integer?
Set buffer to a copy of some raw data.