summaryrefslogtreecommitdiff
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-31 02:24:20 +0000
committerTim Peters <tim.peters@gmail.com>2004-07-31 02:24:20 +0000
commit8d9eb10c299cfaf2f4f8c887ead55da0d24d5050 (patch)
tree5bd69e56069e842216b75e66819adfe70ad56077 /Python/bltinmodule.c
parentbcc95cb7cb8fc26923a089b8606fb46b331bd825 (diff)
downloadcpython-git-8d9eb10c299cfaf2f4f8c887ead55da0d24d5050.tar.gz
Armin asked for a list_ass_slice review in his checkin, so here's the
result. list_resize(): Document the intent. Code is increasingly relying on subtle aspects of its behavior, and they deserve to be spelled out. list_ass_slice(): A bit more simplification, by giving it a common error exit and initializing more values. Be clearer in comments about what "size" means (# of elements? # of bytes?). While the number of elements in a list slice must fit in an int, there's no guarantee that the number of bytes occupied by the slice will. That malloc() and memmove() take size_t arguments is a hint about that <wink>. So changed to use size_t where appropriate. ihigh - ilow should always be >= 0, but we never asserted that. We do now. The loop decref'ing the recycled slice had a subtle insecurity: C doesn't guarantee that a pointer one slot *before* an array will compare "less than" to a pointer within the array (it does guarantee that a pointer one beyond the end of the array compares as expected). This was actually an issue in KSR's C implementation, so isn't purely theoretical. Python probably has other "go backwards" loops with a similar glitch. list_clear() is OK (it marches an integer backwards, not a pointer).
Diffstat (limited to 'Python/bltinmodule.c')
0 files changed, 0 insertions, 0 deletions