8000 gh-76961: Fix the PEP3118 format string for ctypes.Structure by eric-wieser · Pull Request #5561 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

gh-76961: Fix the PEP3118 format string for ctypes.Structure #5561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 5, 2023
Prev Previous commit
Next Next commit
fix incorrect name and documentation
  • Loading branch information
eric-wieser committed Aug 15, 2022
commit 27b1601038a87f76f32bffbabf1877ff9345a520
6 changes: 3 additions & 3 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ MakeAnonFields(PyObject *type)
}

/*
Compute ceil(log10(x)), for the purpose of determining string lengths.
Compute `floor(log10(x)) + 1`, for the purpose of determining string lengths.
*/
static Py_ssize_t
clog10(Py_ssize_t n)
num_digits_of(Py_ssize_t n)
{
Py_ssize_t log_n = 0;
while (n > 0) {
Expand All @@ -371,7 +371,7 @@ _ctypes_alloc_format_padding(const char *prefix, Py_ssize_t padding)
}

/* decimal characters + x + null */
buf = PyMem_Malloc(clog10(padding) + 2);
buf = PyMem_Malloc(num_digits_of(padding) + 2);
if (buf == NULL) {
PyErr_NoMemory();
return NULL;
Expand Down
0