Skip to content

Commit

Permalink
grep: prefer UNUSED to MAYBE_UNUSED for pcre allocators
Browse files Browse the repository at this point in the history
We provide custom malloc/free callbacks for the pcre library to use.
Those take an extra "data" parameter, but we don't use it. Back when
these were added in 513f2b0 (grep: make PCRE2 aware of custom
allocator, 2019-10-16), we only had MAYBE_UNUSED.

But these days we have UNUSED, which we should prefer, as it will
let the compiler inform us if the code changes to actually use the
parameters.

I also moved the annotations to come after the variable name, which is
how we typically spell it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Aug 29, 2024
1 parent 3cdddcf commit 516a9ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int is_fixed(const char *s, size_t len)
#ifdef USE_LIBPCRE2
#define GREP_PCRE2_DEBUG_MALLOC 0

static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data)
static void *pcre2_malloc(PCRE2_SIZE size, void *memory_data UNUSED)
{
void *pointer = malloc(size);
#if GREP_PCRE2_DEBUG_MALLOC
Expand All @@ -255,7 +255,7 @@ static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data)
return pointer;
}

static void pcre2_free(void *pointer, MAYBE_UNUSED void *memory_data)
static void pcre2_free(void *pointer, void *memory_data UNUSED)
{
#if GREP_PCRE2_DEBUG_MALLOC
static int count = 1;
Expand Down

0 comments on commit 516a9ec

Please sign in to comment.