swh:1:snp:32555a3fd8878f019c2ebd6c964bc1edcaeff337
Raw File
Tip revision: 549738f15da0e5a00275977623be199fbbf7df50 authored by Linus Torvalds on 04 October 2020, 23:04:34 UTC
Linux 5.9-rc8
Tip revision: 549738f
libc_compat.h
// SPDX-License-Identifier: (LGPL-2.0+ OR BSD-2-Clause)
/* Copyright (C) 2018 Netronome Systems, Inc. */

#ifndef __TOOLS_LIBC_COMPAT_H
#define __TOOLS_LIBC_COMPAT_H

#include <stdlib.h>
#include <linux/overflow.h>

#ifdef COMPAT_NEED_REALLOCARRAY
static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
{
	size_t bytes;

	if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
		return NULL;
	return realloc(ptr, bytes);
}
#endif
#endif
back to top