linux/tools/include/tools/libc_compat.h
<<
>>
Prefs
   1// SPDX-License-Identifier: (LGPL-2.0+ OR BSD-2-Clause)
   2/* Copyright (C) 2018 Netronome Systems, Inc. */
   3
   4#ifndef __TOOLS_LIBC_COMPAT_H
   5#define __TOOLS_LIBC_COMPAT_H
   6
   7#include <stdlib.h>
   8#include <linux/overflow.h>
   9
  10#ifdef COMPAT_NEED_REALLOCARRAY
  11static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
  12{
  13        size_t bytes;
  14
  15        if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
  16                return NULL;
  17        return realloc(ptr, bytes);
  18}
  19#endif
  20#endif
  21