summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/include/freetype/internal/ftmemory.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/include/freetype/internal/ftmemory.h')
-rw-r--r--src/3rdparty/freetype/include/freetype/internal/ftmemory.h121
1 files changed, 63 insertions, 58 deletions
diff --git a/src/3rdparty/freetype/include/freetype/internal/ftmemory.h b/src/3rdparty/freetype/include/freetype/internal/ftmemory.h
index 054eaec31f..5eb1d21ff6 100644
--- a/src/3rdparty/freetype/include/freetype/internal/ftmemory.h
+++ b/src/3rdparty/freetype/include/freetype/internal/ftmemory.h
@@ -1,19 +1,19 @@
-/***************************************************************************/
-/* */
-/* ftmemory.h */
-/* */
-/* The FreeType memory management macros (specification). */
-/* */
-/* Copyright 1996-2018 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ftmemory.h
+ *
+ * The FreeType memory management macros (specification).
+ *
+ * Copyright (C) 1996-2023 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
#ifndef FTMEMORY_H_
@@ -22,22 +22,23 @@
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
-#include FT_TYPES_H
+#include <freetype/fttypes.h>
+#include "compiler-macros.h"
FT_BEGIN_HEADER
- /*************************************************************************/
- /* */
- /* <Macro> */
- /* FT_SET_ERROR */
- /* */
- /* <Description> */
- /* This macro is used to set an implicit `error' variable to a given */
- /* expression's value (usually a function call), and convert it to a */
- /* boolean which is set whenever the value is != 0. */
- /* */
+ /**************************************************************************
+ *
+ * @macro:
+ * FT_SET_ERROR
+ *
+ * @description:
+ * This macro is used to set an implicit 'error' variable to a given
+ * expression's value (usually a function call), and convert it to a
+ * boolean which is set whenever the value is != 0.
+ */
#undef FT_SET_ERROR
#define FT_SET_ERROR( expression ) \
( ( error = (expression) ) != 0 )
@@ -57,10 +58,18 @@ FT_BEGIN_HEADER
/*************************************************************************/
+ /* The calculation `NULL + n' is undefined in C. Even if the resulting */
+ /* pointer doesn't get dereferenced, this causes warnings with */
+ /* sanitizers. */
+ /* */
+ /* We thus provide a macro that should be used if `base' can be NULL. */
+#define FT_OFFSET( base, count ) ( (base) ? (base) + (count) : NULL )
+
+
/*
- * C++ refuses to handle statements like p = (void*)anything, with `p' a
- * typed pointer. Since we don't have a `typeof' operator in standard
- * C++, we have to use a template to emulate it.
+ * C++ refuses to handle statements like p = (void*)anything, with `p' a
+ * typed pointer. Since we don't have a `typeof' operator in standard C++,
+ * we have to use a template to emulate it.
*/
#ifdef __cplusplus
@@ -87,15 +96,15 @@ extern "C++"
#ifdef FT_DEBUG_MEMORY
- FT_BASE( const char* ) _ft_debug_file;
- FT_BASE( long ) _ft_debug_lineno;
+ FT_BASE( const char* ) ft_debug_file_;
+ FT_BASE( long ) ft_debug_lineno_;
-#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \
- _ft_debug_lineno = __LINE__, \
+#define FT_DEBUG_INNER( exp ) ( ft_debug_file_ = __FILE__, \
+ ft_debug_lineno_ = __LINE__, \
(exp) )
-#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \
- _ft_debug_lineno = __LINE__, \
+#define FT_ASSIGNP_INNER( p, exp ) ( ft_debug_file_ = __FILE__, \
+ ft_debug_lineno_ = __LINE__, \
FT_ASSIGNP( p, exp ) )
#else /* !FT_DEBUG_MEMORY */
@@ -107,8 +116,8 @@ extern "C++"
/*
- * The allocation functions return a pointer, and the error code
- * is written to through the `p_error' parameter.
+ * The allocation functions return a pointer, and the error code is written
+ * to through the `p_error' parameter.
*/
/* The `q' variants of the functions below (`q' for `quick') don't fill */
@@ -153,10 +162,10 @@ extern "C++"
(FT_Long)(size), \
&error ) )
-#define FT_MEM_FREE( ptr ) \
- FT_BEGIN_STMNT \
- ft_mem_free( memory, (ptr) ); \
- (ptr) = NULL; \
+#define FT_MEM_FREE( ptr ) \
+ FT_BEGIN_STMNT \
+ FT_DEBUG_INNER( ft_mem_free( memory, (ptr) ) ); \
+ (ptr) = NULL; \
FT_END_STMNT
#define FT_MEM_NEW( ptr ) \
@@ -253,20 +262,19 @@ extern "C++"
/*
- * Return the maximum number of addressable elements in an array.
- * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
- * any problems.
+ * Return the maximum number of addressable elements in an array. We limit
+ * ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems.
*/
#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
- /*************************************************************************/
- /* */
- /* The following functions macros expect that their pointer argument is */
- /* _typed_ in order to automatically compute array element sizes. */
- /* */
+ /**************************************************************************
+ *
+ * The following functions macros expect that their pointer argument is
+ * _typed_ in order to automatically compute array element sizes.
+ */
#define FT_MEM_NEW_ARRAY( ptr, count ) \
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \
@@ -336,14 +344,13 @@ extern "C++"
#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) )
-#define FT_QNEW( ptr ) \
- FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) )
+#define FT_QNEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) )
-#define FT_QNEW_ARRAY( ptr, count ) \
- FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) )
+#define FT_QNEW_ARRAY( ptr, count ) \
+ FT_MEM_SET_ERROR( FT_MEM_QNEW_ARRAY( ptr, count ) )
-#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \
- FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) )
+#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \
+ FT_MEM_SET_ERROR( FT_MEM_QRENEW_ARRAY( ptr, curcnt, newcnt ) )
FT_BASE( FT_Pointer )
@@ -382,8 +389,6 @@ extern "C++"
#define FT_STRCPYN( dst, src, size ) \
ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) )
- /* */
-
FT_END_HEADER