Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(27463)

Side by Side Diff: Include/objimpl.h

Issue 13390: Hunt memory allocations in addition to reference leaks
Patch Set: Created 7 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/test/regrtest.py » ('j') | Objects/obmalloc.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* The PyObject_ memory family: high-level object memory interfaces. 1 /* The PyObject_ memory family: high-level object memory interfaces.
2 See pymem.h for the low-level PyMem_ family. 2 See pymem.h for the low-level PyMem_ family.
3 */ 3 */
4 4
5 #ifndef Py_OBJIMPL_H 5 #ifndef Py_OBJIMPL_H
6 #define Py_OBJIMPL_H 6 #define Py_OBJIMPL_H
7 7
8 #include "pymem.h" 8 #include "pymem.h"
9 9
10 #ifdef __cplusplus 10 #ifdef __cplusplus
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 For allocating objects, use PyObject_{New, NewVar} instead whenever 90 For allocating objects, use PyObject_{New, NewVar} instead whenever
91 possible. The PyObject_{Malloc, Realloc, Free} family is exposed 91 possible. The PyObject_{Malloc, Realloc, Free} family is exposed
92 so that you can exploit Python's small-block allocator for non-object 92 so that you can exploit Python's small-block allocator for non-object
93 uses. If you must use these routines to allocate object memory, make sure 93 uses. If you must use these routines to allocate object memory, make sure
94 the object gets initialized via PyObject_{Init, InitVar} after obtaining 94 the object gets initialized via PyObject_{Init, InitVar} after obtaining
95 the raw memory. 95 the raw memory.
96 */ 96 */
97 PyAPI_FUNC(void *) PyObject_Malloc(size_t); 97 PyAPI_FUNC(void *) PyObject_Malloc(size_t);
98 PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t); 98 PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t);
99 PyAPI_FUNC(void) PyObject_Free(void *); 99 PyAPI_FUNC(void) PyObject_Free(void *);
100
101 /* This is the number of allocated memory blocks, regardless of size */
102 PyAPI_DATA(Py_ssize_t) _Py_AllocedBlocks;
Nick Coghlan 2011/11/13 01:52:44 Do you have any particular reason for only exposin
100 103
101 104
102 /* Macros */ 105 /* Macros */
103 #ifdef WITH_PYMALLOC 106 #ifdef WITH_PYMALLOC
104 #ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */ 107 #ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
105 PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes); 108 PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
106 PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes); 109 PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
107 PyAPI_FUNC(void) _PyObject_DebugFree(void *p); 110 PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
108 PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p); 111 PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p);
109 PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p); 112 PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 /* Test if a type supports weak references */ 332 /* Test if a type supports weak references */
330 #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) 333 #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
331 334
332 #define PyObject_GET_WEAKREFS_LISTPTR(o) \ 335 #define PyObject_GET_WEAKREFS_LISTPTR(o) \
333 ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) 336 ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
334 337
335 #ifdef __cplusplus 338 #ifdef __cplusplus
336 } 339 }
337 #endif 340 #endif
338 #endif /* !Py_OBJIMPL_H */ 341 #endif /* !Py_OBJIMPL_H */
OLDNEW
« no previous file with comments | « no previous file | Lib/test/regrtest.py » ('j') | Objects/obmalloc.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+