Cleanup: Move internal guardedalloc headers to C++.
Pull Request: https://projects.blender.org/blender/blender/pulls/124106
This commit is contained in:
parent
e2d77fbc1c
commit
4afb48acad
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
# Used for: `intern/guardedalloc/intern/mallocn_intern.h`.
|
# Used for: `intern/guardedalloc/intern/mallocn_intern.hh`.
|
||||||
# Function `malloc_stats` is only available on GLIBC,
|
# Function `malloc_stats` is only available on GLIBC,
|
||||||
# so check that before defining `HAVE_MALLOC_STATS`.
|
# so check that before defining `HAVE_MALLOC_STATS`.
|
||||||
check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H)
|
check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H)
|
||||||
|
@ -26,8 +26,8 @@ set(SRC
|
|||||||
./intern/memory_usage.cc
|
./intern/memory_usage.cc
|
||||||
|
|
||||||
MEM_guardedalloc.h
|
MEM_guardedalloc.h
|
||||||
./intern/mallocn_inline.h
|
./intern/mallocn_inline.hh
|
||||||
./intern/mallocn_intern.h
|
./intern/mallocn_intern.hh
|
||||||
|
|
||||||
# only so the header is known by cmake
|
# only so the header is known by cmake
|
||||||
../atomic/atomic_ops.h
|
../atomic/atomic_ops.h
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
#include "mallocn_intern.h"
|
#include "mallocn_intern.hh"
|
||||||
|
|
||||||
bool leak_detector_has_run = false;
|
bool leak_detector_has_run = false;
|
||||||
char free_after_leak_detection_message[] =
|
char free_after_leak_detection_message[] =
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "mallocn_intern.h"
|
#include "mallocn_intern.hh"
|
||||||
|
|
||||||
#ifdef WITH_JEMALLOC_CONF
|
#ifdef WITH_JEMALLOC_CONF
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
||||||
|
|
||||||
#include "atomic_ops.h"
|
#include "atomic_ops.h"
|
||||||
#include "mallocn_intern.h"
|
#include "mallocn_intern.hh"
|
||||||
|
|
||||||
/* Only for debugging:
|
/* Only for debugging:
|
||||||
* store original buffer's name when doing MEM_dupallocN
|
* store original buffer's name when doing MEM_dupallocN
|
||||||
|
@ -3,18 +3,12 @@
|
|||||||
* SPDX-FileCopyrightText: 2009-2017 Facebook, Inc. All rights reserved.
|
* SPDX-FileCopyrightText: 2009-2017 Facebook, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause */
|
* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \ingroup intern_mem
|
* \ingroup intern_mem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MALLOCN_INLINE_H__
|
|
||||||
#define __MALLOCN_INLINE_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MEM_INLINE bool MEM_size_safe_multiply(size_t a, size_t b, size_t *result)
|
MEM_INLINE bool MEM_size_safe_multiply(size_t a, size_t b, size_t *result)
|
||||||
{
|
{
|
||||||
/* A size_t with its high-half bits all set to 1. */
|
/* A size_t with its high-half bits all set to 1. */
|
||||||
@ -33,9 +27,3 @@ MEM_INLINE bool MEM_size_safe_multiply(size_t a, size_t b, size_t *result)
|
|||||||
*/
|
*/
|
||||||
return ((high_bits & (a | b)) == 0 || (*result / b == a));
|
return ((high_bits & (a | b)) == 0 || (*result / b == a));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MALLOCN_INLINE_H__ */
|
|
@ -1,14 +1,12 @@
|
|||||||
/* SPDX-FileCopyrightText: 2013 Blender Authors
|
/* SPDX-FileCopyrightText: 2013 Blender Authors
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
#pragma once
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \ingroup intern_mem
|
* \ingroup intern_mem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MALLOCN_INTERN_H__
|
|
||||||
#define __MALLOCN_INTERN_H__
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
# define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
@ -95,11 +93,7 @@ size_t malloc_usable_size(void *ptr);
|
|||||||
/* Real pointer returned by the malloc or aligned_alloc. */
|
/* Real pointer returned by the malloc or aligned_alloc. */
|
||||||
#define MEMHEAD_REAL_PTR(memh) ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))
|
#define MEMHEAD_REAL_PTR(memh) ((char *)memh - MEMHEAD_ALIGN_PADDING(memh->alignment))
|
||||||
|
|
||||||
#include "mallocn_inline.h"
|
#include "mallocn_inline.hh"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT sizeof(void *)
|
#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT sizeof(void *)
|
||||||
|
|
||||||
@ -227,9 +221,3 @@ void mem_guarded_clearmemlist(void);
|
|||||||
const char *MEM_guarded_name_ptr(void *vmemh);
|
const char *MEM_guarded_name_ptr(void *vmemh);
|
||||||
void MEM_guarded_name_ptr_set(void *vmemh, const char *str);
|
void MEM_guarded_name_ptr_set(void *vmemh, const char *str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MALLOCN_INTERN_H__ */
|
|
@ -26,7 +26,7 @@
|
|||||||
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
||||||
|
|
||||||
#include "atomic_ops.h"
|
#include "atomic_ops.h"
|
||||||
#include "mallocn_intern.h"
|
#include "mallocn_intern.hh"
|
||||||
|
|
||||||
typedef struct MemHead {
|
typedef struct MemHead {
|
||||||
/* Length of allocated memory block. */
|
/* Length of allocated memory block. */
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
#include "mallocn_intern.h"
|
#include "mallocn_intern.hh"
|
||||||
|
|
||||||
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
#include "../../source/blender/blenlib/BLI_strict_flags.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user