From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Puiu Subject: Re: Use rte_malloc in application Date: Thu, 3 Aug 2017 16:29:44 +0300 Message-ID: References: <3d5197fb36ef4901907d785621f01da5@stellus.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: "dev@dpdk.org" To: "Rohit Saini (Stellus)" Return-path: Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.161.196]) by dpdk.org (Postfix) with ESMTP id 28F3D2BC9 for ; Thu, 3 Aug 2017 15:29:46 +0200 (CEST) Received: by mail-yw0-f196.google.com with SMTP id s143so802599ywg.4 for ; Thu, 03 Aug 2017 06:29:46 -0700 (PDT) In-Reply-To: <3d5197fb36ef4901907d785621f01da5@stellus.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, This is not strictly DPDK-related, but still... On Thu, Aug 3, 2017 at 9:12 AM, Rohit Saini (Stellus) wrote: > With below code, I am getting this warning. > > warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] > > my_node_t *data_ptr = (my_node_t *) rte_malloc(NULL, sizeof(my_node_t), 0); I think the warning concerns the first argument passed to rte_malloc. NULL probably expands to 0 (at least that seems to happen in C++), so it gets treated as an int instead of a pointer. In C++11, there's nullptr for this; or you could simply use a non-NULL string. HTH, Stefan. > > Thanks, > Rohit > > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Rohit Saini (Stellus) > Sent: Thursday, August 03, 2017 11:28 AM > To: 'dev@dpdk.org' > Subject: [dpdk-dev] Use rte_malloc in application > > Hi, > I have a use case in my application where I need to implement my own memory manager, rather than doing malloc/free everytime to kernel. > Instead of writing my own memory manager, I am thinking to use dpdk rte_malloc or rte_mempool. Please let me know if this is a good idea. > > Also, > > my_node_t *data_ptr = (my_node_t *) (uintptr_t) rte_malloc(NULL, sizeof(my_node_t), 0); > > data_ptr is pointing to some invalid memory. Am I doing anything wrong here? > > > Thanks, > Rohit