// SPDX-License-Identifier: GPL-2.0-or-later // // for lwIP, shadowing the host's. See shim/string.h for why these // files exist at all. // // lwIP does not need an allocator from here: MEM_LIBC_MALLOC is off, so it uses // its own pools out of a static heap. That is not a workaround -- the kernel's // allocator hands out whole pages and lwIP wants byte granularity, so its pools // are the better fit either way. // // atoi is the one thing it genuinely calls, in netif_name_to_index, to turn the // digits at the end of an interface name into a number. #ifndef LWIP_SHIM_STDLIB_H #define LWIP_SHIM_STDLIB_H // Deliberately not a general atoi: no sign, no whitespace, no overflow // handling. It is fed the tail of an interface name ("en0" -> "0"), and // anything cleverer would be untested code answering a question nobody asks. static inline int atoi(const char *s) { int n = 0; while (*s >= '0' && *s <= '9') n = n * 10 + (*s++ - '0'); return n; } #endif