From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4DD76428D4; Wed, 5 Apr 2023 17:25:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2ED9141153; Wed, 5 Apr 2023 17:25:24 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8CEBD41133 for ; Wed, 5 Apr 2023 17:25:22 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id BAFB0210DED5; Wed, 5 Apr 2023 08:25:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BAFB0210DED5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680708321; bh=8SK9noaIW8ePzcE12b5xofWHirEEQDZXfvehBVfUTIs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZegJwEr6mw4ZA0WhN9VkYq4Hsk/mpc+FYqoypifrdRZPkKyPxhwDJ69czje06/2kN dJdsvRqNblhYrUMY/gdDZGNrAlb1YwbfXtmy5UgWWw4z7TGHOfcgCHFHN6c/OLxMsO 19DRtldbub22zub/C7gjnNo8EdbgUSDmoMLtwepo= Date: Wed, 5 Apr 2023 08:25:21 -0700 From: Tyler Retzlaff To: Bruce Richardson Cc: Stephen Hemminger , dev@dpdk.org, ciara.power@intel.com, david.marchand@redhat.com, thomas@monjalon.net Subject: Re: [PATCH 1/2] telemetry: use malloc instead of variable length array Message-ID: <20230405152521.GB28418@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680539424-20255-2-git-send-email-roretzla@linux.microsoft.com> <20230403131913.0aec54ce@hermes.local> <20230404180432.2dc01862@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 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.