[docs] [issue17042] Example in C-API memory management doc has confusing order
Eric Snow
report at bugs.python.org
Sun Jan 27 01:14:02 CET 2013
Eric Snow added the comment:
Sorry, I'd meant something like this:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
char *buf1 = PyMem_New(char, BUFSIZ);
char *buf2 = (char *) malloc(BUFSIZ);
char *buf3 = (char *) PyMem_Malloc(BUFSIZ);
...
/* in reverse order */
PyMem_Del(buf3); /* Wrong -- should be PyMem_Free() */
free(buf2); /* Right -- allocated via malloc() */
free(buf1); /* Fatal -- should be PyMem_Del() */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This will help if someone does not know the common pattern.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17042>
_______________________________________
More information about the docs
mailing list