[docs] [issue17042] Example in C-API memory management doc has confusing order
Eric Snow
report at bugs.python.org
Sat Jan 26 19:20:38 CET 2013
New submission from Eric Snow:
In http://docs.python.org/dev/c-api/memory.html#examples:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
char *buf1 = PyMem_New(char, BUFSIZ);
char *buf2 = (char *) malloc(BUFSIZ);
char *buf3 = (char *) PyMem_Malloc(BUFSIZ);
...
PyMem_Del(buf3); /* Wrong -- should be PyMem_Free() */
free(buf2); /* Right -- allocated via malloc() */
free(buf1); /* Fatal -- should be PyMem_Del() */
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is there a good reason to have the second set of 3 lines in the opposite order as the first three? At first I missed that they were in a different order and thought there was an error in the example. If there's no good reason for the order, it would be worth fixing. If there is a good reason, a comment in the example would help. Either way I'd be glad to patch it (will go ahead with fixing the ordering later today if no one does it first).
----------
assignee: docs at python
components: Documentation
messages: 180697
nosy: docs at python, eric.snow
priority: low
severity: normal
stage: needs patch
status: open
title: Example in C-API memory management doc has confusing order
versions: Python 2.7, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17042>
_______________________________________
More information about the docs
mailing list