[PATCH 02/12] net: add function to pretty print IPv4
Morten Brørup
mb at smartsharesystems.com
Tue Dec 14 18:42:35 CET 2021
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Tuesday, 14 December 2021 17.09
>
> On Tue, 14 Dec 2021 14:12:32 +0000
> Ronan Randles <ronan.randles at intel.com> wrote:
>
> > This function accepts an uint32_t representation of an IP address and
> > produces a string representation stored in a char * buffer. Realavent
> > unit tests also included.
> >
> > Signed-off-by: Ronan Randles <ronan.randles at intel.com>
>
> Do we really have to reinvent getnameinfo()?
> Is this for Windows?
For general inspiration:
We have an in-house to/from string library, where our xx_to_str() functions return char * and can take a NULL pointer as the buffer parameter to make it use a buffer from an small cyclic pool of string buffers in the library.
Probably not good from an academic standpoint, and not good for a generic library, but we know how many of these strings are being used simultaneously in our applications, so the pool is not overrun in reality. And it makes the code using these functions much shorter and readable.
-Morten
More information about the dev
mailing list