~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Include/pymem.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
 */
91
91
 
92
92
#define PyMem_New(type, n) \
93
 
  ( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
 
93
  ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :      \
94
94
        ( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
95
95
#define PyMem_NEW(type, n) \
96
 
  ( ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
 
96
  ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :      \
97
97
        ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
98
98
 
99
99
/*
103
103
 * caller's memory error handler to not lose track of it.
104
104
 */
105
105
#define PyMem_Resize(p, type, n) \
106
 
  ( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
 
106
  ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :        \
107
107
        (type *) PyMem_Realloc((p), (n) * sizeof(type)) )
108
108
#define PyMem_RESIZE(p, type, n) \
109
 
  ( (p) = ((n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
 
109
  ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL :        \
110
110
        (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
111
111
 
112
112
/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used