PHP 8.2.30
Preview: pymem.h Size: 3.80 KB
//opt/alt/python310/include/python3.10/pymem.h

/* The PyMem_ family:  low-level memory allocation interfaces.
   See objimpl.h for the PyObject_ memory family.
*/

#ifndef Py_PYMEM_H
#define Py_PYMEM_H

#include "pyport.h"

#ifdef __cplusplus
extern "C" {
#endif

/* BEWARE:

   Each interface exports both functions and macros.  Extension modules should
   use the functions, to ensure binary compatibility across Python versions.
   Because the Python implementation is free to change internal details, and
   the macros may (or may not) expose details for speed, if you do use the
   macros you must recompile your extensions with each Python release.

   Never mix calls to PyMem_ with calls to the platform malloc/realloc/
   calloc/free.  For example, on Windows different DLLs may end up using
   different heaps, and if you use PyMem_Malloc you'll get the memory from the
   heap used by the Python DLL; it could be a disaster if you free()'ed that
   directly in your own extension.  Using PyMem_Free instead ensures Python
   can return the memory to the proper heap.  As another example, in
   a debug build (Py_DEBUG macro), Python wraps all calls to all PyMem_ and
   PyObject_ memory functions in special debugging wrappers that add additional
   debugging info to dynamic memory blocks.  The system routines have no idea
   what to do with that stuff, and the Python wrappers have no idea what to do
   with raw blocks obtained directly by the system routines then.

   The GIL must be held when using these APIs.
*/

/*
 * Raw memory interface
 * ====================
 */

/* Functions

   Functions supplying platform-independent semantics for malloc/realloc/
   free.  These functions make sure that allocating 0 bytes returns a distinct
   non-NULL pointer (whenever possible -- if we're flat out of memory, NULL
   may be returned), even if the platform malloc and realloc don't.
   Returned pointers must be checked for NULL explicitly.  No action is
   performed on failure (no exception is set, no warning is printed, etc).
*/

PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);

/*
 * Type-oriented memory interface
 * ==============================
 *
 * Allocate memory for n objects of the given type.  Returns a new pointer
 * or NULL if the request was too large or memory allocation failed.  Use
 * these macros rather than doing the multiplication yourself so that proper
 * overflow checking is always done.
 */

#define PyMem_New(type, n) \
  ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :      \
        ( (type *) PyMem_Malloc((n) * sizeof(type)) ) )

/*
 * The value of (p) is always clobbered by this macro regardless of success.
 * The caller MUST check if (p) is NULL afterwards and deal with the memory
 * error if so.  This means the original value of (p) MUST be saved for the
 * caller's memory error handler to not lose track of it.
 */
#define PyMem_Resize(p, type, n) \
  ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :        \
        (type *) PyMem_Realloc((p), (n) * sizeof(type)) )


// Deprecated aliases only kept for backward compatibility.
// PyMem_Del and PyMem_DEL are defined with no parameter to be able to use
// them as function pointers (ex: dealloc = PyMem_Del).
#define PyMem_MALLOC(n)           PyMem_Malloc(n)
#define PyMem_NEW(type, n)        PyMem_New(type, n)
#define PyMem_REALLOC(p, n)       PyMem_Realloc(p, n)
#define PyMem_RESIZE(p, type, n)  PyMem_Resize(p, type, n)
#define PyMem_FREE(p)             PyMem_Free(p)
#define PyMem_Del                 PyMem_Free
#define PyMem_DEL                 PyMem_Free


#ifndef Py_LIMITED_API
#  define Py_CPYTHON_PYMEM_H
#  include  "cpython/pymem.h"
#  undef Py_CPYTHON_PYMEM_H
#endif

#ifdef __cplusplus
}
#endif

#endif /* !Py_PYMEM_H */

Directory Contents

Dirs: 2 × Files: 83

Name Size Perms Modified Actions
cpython DIR
- drwxr-xr-x 2026-02-10 08:08:38
Edit Download
internal DIR
- drwxr-xr-x 2026-02-10 08:08:38
Edit Download
30.67 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
264 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.20 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.45 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.53 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
720 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
5.57 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.62 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
318 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
6.91 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
520 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.76 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.92 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
9.41 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.93 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.76 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
21.94 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
253 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.66 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
831 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.07 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.53 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
508 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
4.26 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
337 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
4.16 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
334 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.27 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.96 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
334 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
772 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
593 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.74 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.71 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
8.40 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
803 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.70 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
4.05 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
10.09 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.40 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
349 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
27.68 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
8.25 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
5.38 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
737 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
291 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.27 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.68 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
47.55 KB lrw-r--r-- 2026-01-09 13:55:06
Edit Download
162 B lrw-r--r-- 2026-01-09 14:05:53
Edit Download
2.36 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
12.13 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.51 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
466 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
4.12 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.03 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.92 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
4.80 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
8.12 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.80 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
30.94 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
5.13 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
436 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
849 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.45 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.15 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.08 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
5.80 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.42 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
628 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
3.30 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.46 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.03 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.36 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.21 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.61 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
584 B lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.09 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.58 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.40 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
35.30 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
1.73 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download
2.80 KB lrw-r--r-- 2025-10-09 15:25:03
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).