Skip to content

Commit 9093ced

Browse files
committed
patch_generate: represent buffers as void pointers
Pointers to general data should usually be used as a void pointer such that it is possible to hand in variables of a different pointer type without the need to cast. This is the same when creating patches from buffers, where the buffers may contain arbitrary data. Instead of requiring the caller to care whether his buffer is e.g. `char *` or `unsigned char *`, we should instead just accept a `void *`. This is also consistent in how we tread other types like for example `git_blob`, which also just has a void pointer as its raw contents.
1 parent 0e16568 commit 9093ced

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/git2/patch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ GIT_EXTERN(int) git_patch_from_blob_and_buffer(
9696
git_patch **out,
9797
const git_blob *old_blob,
9898
const char *old_as_path,
99-
const char *buffer,
99+
const void *buffer,
100100
size_t buffer_len,
101101
const char *buffer_as_path,
102102
const git_diff_options *opts);
@@ -124,7 +124,7 @@ GIT_EXTERN(int) git_patch_from_buffers(
124124
const void *old_buffer,
125125
size_t old_len,
126126
const char *old_as_path,
127-
const char *new_buffer,
127+
const void *new_buffer,
128128
size_t new_len,
129129
const char *new_as_path,
130130
const git_diff_options *opts);

src/patch_generate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ int git_patch_from_blob_and_buffer(
641641
git_patch **out,
642642
const git_blob *old_blob,
643643
const char *old_path,
644-
const char *buf,
644+
const void *buf,
645645
size_t buflen,
646646
const char *buf_path,
647647
const git_diff_options *opts)
@@ -680,7 +680,7 @@ int git_patch_from_buffers(
680680
const void *old_buf,
681681
size_t old_len,
682682
const char *old_path,
683-
const char *new_buf,
683+
const void *new_buf,
684684
size_t new_len,
685685
const char *new_path,
686686
const git_diff_options *opts)

0 commit comments

Comments
 (0)