diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-09 18:25:10 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-17 21:17:32 +0000 |
commit | 22d2062d954dcb88fa3dc65281d3f3d88ae87d68 (patch) | |
tree | 22852e22d6c571be8ccc1cdaece3d926360fc191 /include/git2/sys/alloc.h | |
parent | 57b753a0dc0db2d89341300470653e8a4d066c0b (diff) | |
download | libgit2-22d2062d954dcb88fa3dc65281d3f3d88ae87d68.tar.gz |
Introduce GIT_CALLBACK macro to enforce cdecl
Since we now always build the library with cdecl calling conventions,
our callbacks should be decorated as such so that users will not be able
to provide callbacks defined with other calling conventions.
The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as
appropriate.
Diffstat (limited to 'include/git2/sys/alloc.h')
-rw-r--r-- | include/git2/sys/alloc.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/include/git2/sys/alloc.h b/include/git2/sys/alloc.h index 4bc5323e2..642740dab 100644 --- a/include/git2/sys/alloc.h +++ b/include/git2/sys/alloc.h @@ -22,54 +22,54 @@ GIT_BEGIN_DECL */ typedef struct { /* Allocate `n` bytes of memory */ - void *(*gmalloc)(size_t n, const char *file, int line); + void * GIT_CALLBACK(gmalloc)(size_t n, const char *file, int line); /* * Allocate memory for an array of `nelem` elements, where each element * has a size of `elsize`. Returned memory shall be initialized to * all-zeroes */ - void *(*gcalloc)(size_t nelem, size_t elsize, const char *file, int line); + void * GIT_CALLBACK(gcalloc)(size_t nelem, size_t elsize, const char *file, int line); /* Allocate memory for the string `str` and duplicate its contents. */ - char *(*gstrdup)(const char *str, const char *file, int line); + char * GIT_CALLBACK(gstrdup)(const char *str, const char *file, int line); /* * Equivalent to the `gstrdup` function, but only duplicating at most * `n + 1` bytes */ - char *(*gstrndup)(const char *str, size_t n, const char *file, int line); + char * GIT_CALLBACK(gstrndup)(const char *str, size_t n, const char *file, int line); /* * Equivalent to `gstrndup`, but will always duplicate exactly `n` bytes * of `str`. Thus, out of bounds reads at `str` may happen. */ - char *(*gsubstrdup)(const char *str, size_t n, const char *file, int line); + char * GIT_CALLBACK(gsubstrdup)(const char *str, size_t n, const char *file, int line); /* * 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. */ - void *(*grealloc)(void *ptr, size_t size, const char *file, int line); + void * GIT_CALLBACK(grealloc)(void *ptr, size_t size, const char *file, int line); /* * This function shall be equivalent to `grealloc`, but allocating * `neleme * elsize` bytes. */ - void *(*greallocarray)(void *ptr, size_t nelem, size_t elsize, const char *file, int line); + void * GIT_CALLBACK(greallocarray)(void *ptr, size_t nelem, size_t elsize, const char *file, int line); /* * This function shall allocate a new array of `nelem` elements, where * each element has a size of `elsize` bytes. */ - void *(*gmallocarray)(size_t nelem, size_t elsize, const char *file, int line); + void * GIT_CALLBACK(gmallocarray)(size_t nelem, size_t elsize, const char *file, int line); /* * This function shall free the memory pointed to by `ptr`. In case * `ptr` is `NULL`, this shall be a no-op. */ - void (*gfree)(void *ptr); + void GIT_CALLBACK(gfree)(void *ptr); } git_allocator; /** |