comparison mercurial/dirs.c @ 30159:fb5504d7b2c9

dirs: document Py_SIZE weirdness Assigning to what looks like a function is clown shoes. Document that it is a macro referring to a struct member.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 08 Oct 2016 17:07:43 +0200
parents 27e00e6352ce
children 1e5ff5ae1d2b
comparison
equal deleted inserted replaced
30158:1baa0e2cfc37 30159:fb5504d7b2c9
74 key = PyBytes_FromStringAndSize(cpath, 74 key = PyBytes_FromStringAndSize(cpath,
75 pos < 2 ? 2 : pos); 75 pos < 2 ? 2 : pos);
76 if (key == NULL) 76 if (key == NULL)
77 goto bail; 77 goto bail;
78 } 78 }
79 /* Py_SIZE(o) refers to the ob_size member of the struct. Yes,
80 * assigning to what looks like a function seems wrong. */
79 Py_SIZE(key) = pos; 81 Py_SIZE(key) = pos;
80 ((PyBytesObject *)key)->ob_sval[pos] = '\0'; 82 ((PyBytesObject *)key)->ob_sval[pos] = '\0';
81 83
82 val = PyDict_GetItem(dirs, key); 84 val = PyDict_GetItem(dirs, key);
83 if (val != NULL) { 85 if (val != NULL) {