lint: only define xcalloc if actually used

This commit is contained in:
rillig 2024-01-20 10:21:35 +00:00
parent 45efdafbcc
commit e6919d40e3
2 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs.h,v 1.31 2023/12/03 18:17:41 rillig Exp $ */
/* $NetBSD: externs.h,v 1.32 2024/01/20 10:21:35 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -43,7 +43,9 @@ const char *tspec_name(tspec_t);
* mem.c
*/
void *xmalloc(size_t);
#if defined(IS_LINT1) || defined(IS_LINT2)
void *xcalloc(size_t, size_t);
#endif
void *xrealloc(void *, size_t);
char *xstrdup(const char *);
char *xasprintf(const char *, ...) __printflike(1, 2);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.22 2023/07/13 08:40:38 rillig Exp $ */
/* $NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
__RCSID("$NetBSD: mem.c,v 1.22 2023/07/13 08:40:38 rillig Exp $");
__RCSID("$NetBSD: mem.c,v 1.23 2024/01/20 10:21:35 rillig Exp $");
#endif
#include <stdarg.h>
@ -62,12 +62,14 @@ xmalloc(size_t s)
return not_null(malloc(s));
}
#if defined(IS_LINT1) || defined(IS_LINT2)
void *
xcalloc(size_t n, size_t s)
{
return not_null(calloc(n, s));
}
#endif
void *
xrealloc(void *p, size_t s)