Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e9e74525
Commit
e9e74525
authored
Apr 12, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First cut at repairing out-of-date comments; make alignment of macro defs
all the same within the #ifdef WITH_PYMALLOC block.
parent
d2560cd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
15 deletions
+24
-15
Include/objimpl.h
Include/objimpl.h
+24
-15
No files found.
Include/objimpl.h
View file @
e9e74525
...
...
@@ -17,15 +17,17 @@ You must first include "object.h".
represent the object and 'typeobj' the address of the corresponding
type object. Reference count and type pointer are filled in; the
rest of the bytes of the object are *undefined*! The resulting
expression type is 'type *'. The size of the object is
actually
determined
by the tp_basicsize field of the type object.
expression type is 'type *'. The size of the object is
determined
by the tp_basicsize field of the type object.
- PyObject_NewVar(type, typeobj, n) is similar but allocates a
variable-size object with n extra items. The size is computed as
tp_basicsize plus n * tp_itemsize. This fills in the ob_size field
as well.
- PyObject_Del(op) releases the memory allocated for an object.
- PyObject_Del(op) releases the memory allocated for an object. It
does not run a destructor -- it only frees the memory. PyObject_Free
is identical.
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) are
similar to PyObject_{New, NewVar} except that they don't allocate
...
...
@@ -34,7 +36,9 @@ You must first include "object.h".
allocator) and initialize its object header fields.
Note that objects created with PyObject_{New, NewVar} are allocated
using the specialized Python allocator (implemented in obmalloc.c).
using the specialized Python allocator (implemented in obmalloc.c), if
WITH_PYMALLOC is enabled. In addition, a special debugging allocator
is used if PYMALLOC_DEBUG is also #defined.
In case a specific form of memory management is needed, implying that
the objects would not reside in the Python heap (for example standard
...
...
@@ -70,11 +74,16 @@ recommended to use PyObject_{New, NewVar, Del}. */
/* Functions */
/* Wrappers that useful if you need to be sure that you are using the
same object memory allocator as Python. These wrappers *do not* make
sure that allocating 0 bytes returns a non-NULL pointer. Returned
pointers must be checked for NULL explicitly; no action is performed
on failure. */
/* Functions to call the same malloc/realloc/free as used by Python's
object allocator. If WITH_PYMALLOC is enabled, these may differ from
the platform malloc/realloc/free. The Python object allocator is
designed for fast, cache-conscious allocation of many "small" objects,
with low hidden memory overhead. PyObject_Malloc(0) returns a unique
non-NULL pointer if possible. PyObject_Realloc(NULL, n) acts like
PyObject_Malloc(n). PyObject_Realloc(p != NULL, 0) does not return
NULL or free the memory at p. Returned pointers must be checked for
NULL explicitly; no action is performed on failure other than to return
NULL. */
extern
DL_IMPORT
(
void
*
)
PyObject_Malloc
(
size_t
);
extern
DL_IMPORT
(
void
*
)
PyObject_Realloc
(
void
*
,
size_t
);
extern
DL_IMPORT
(
void
)
PyObject_Free
(
void
*
);
...
...
@@ -89,12 +98,12 @@ DL_IMPORT(void) _PyObject_DebugFree(void *p);
DL_IMPORT
(
void
)
_PyObject_DebugDumpAddress
(
const
void
*
p
);
DL_IMPORT
(
void
)
_PyObject_DebugCheckAddress
(
const
void
*
p
);
DL_IMPORT
(
void
)
_PyObject_DebugDumpStats
(
void
);
#define PyObject_MALLOC
_PyObject_DebugMalloc
#define PyObject_Malloc
_PyObject_DebugMalloc
#define PyObject_REALLOC
_PyObject_DebugRealloc
#define PyObject_Realloc
_PyObject_DebugRealloc
#define PyObject_FREE
_PyObject_DebugFree
#define PyObject_Free
_PyObject_DebugFree
#define PyObject_MALLOC
_PyObject_DebugMalloc
#define PyObject_Malloc
_PyObject_DebugMalloc
#define PyObject_REALLOC
_PyObject_DebugRealloc
#define PyObject_Realloc
_PyObject_DebugRealloc
#define PyObject_FREE
_PyObject_DebugFree
#define PyObject_Free
_PyObject_DebugFree
#else
/* WITH_PYMALLOC && ! PYMALLOC_DEBUG */
#define PyObject_MALLOC PyObject_Malloc
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment