On Wed, 5 Apr 2023 18:30:51 +0300 Dmitry Kozlyuk <dmitry.kozl...@gmail.com> wrote:
> 2023-04-05 08:25 (UTC-0700), Tyler Retzlaff: > > On Wed, Apr 05, 2023 at 09:54:46AM +0100, Bruce Richardson wrote: > > > On Tue, Apr 04, 2023 at 06:04:32PM -0700, Stephen Hemminger wrote: > > > > On Tue, 4 Apr 2023 09:47:21 +0100 > > > > Bruce Richardson <bruce.richard...@intel.com> wrote: > > > > > > > > > My suggestion is to use a combination of these methods. In > > > > > json_snprintf > > > > > check if the input buffer is empty or has only one character in it, > > > > > and use > > > > > method #2 if so. If that's not the case, then fallback to method #1 > > > > > and do > > > > > a double snprintf. > > > > > > > > > > Make sense? Any other suggestions? > > > > > > > > Glibc has asprintf which allocates the buffer for you. > > > > > > Good point, I'll use that in any new implementation. Thanks. > > > > i imagine there is an equivalent to asprintf for windows but keep in > > mind it is not standard C so you'll have to do something conditional. > > There's eal_asprintf() shim in EAL, > we could make it internal to reuse in telemetry. Windows has tools necessary to build asprint equivalent. See: https://github.com/eiszapfen2000/asprintf