From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6450 invoked by alias); 28 Aug 2013 13:14:51 -0000 Mailing-List: contact ecos-devel-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-devel-owner@ecos.sourceware.org Received: (qmail 6440 invoked by uid 89); 28 Aug 2013 13:14:51 -0000 Received: from mail-bk0-f46.google.com (HELO mail-bk0-f46.google.com) (209.85.214.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 28 Aug 2013 13:14:51 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,FREEMAIL_FROM,KHOP_THREADED autolearn=ham version=3.3.2 X-HELO: mail-bk0-f46.google.com Received: by mail-bk0-f46.google.com with SMTP id 6so2112336bkj.19 for ; Wed, 28 Aug 2013 06:14:47 -0700 (PDT) X-Received: by 10.204.232.207 with SMTP id jv15mr42445bkb.39.1377695686937; Wed, 28 Aug 2013 06:14:46 -0700 (PDT) Received: from sg-pc.belvok.com ([86.57.137.251]) by mx.google.com with ESMTPSA id no2sm5952700bkb.15.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 28 Aug 2013 06:14:45 -0700 (PDT) Date: Wed, 28 Aug 2013 13:14:00 -0000 From: Sergei Gavrikov To: =?UTF-8?Q?Max_Seidenst=C3=BCcker?= cc: ecos-devel@ecos.sourceware.org Subject: Re: Elegant substitute for kzalloc() through #define? In-Reply-To: <1377692630382-242405.post@n7.nabble.com> Message-ID: References: <1377692630382-242405.post@n7.nabble.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463803648-322360879-1377695685=:9922" X-SW-Source: 2013-08/txt/msg00008.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463803648-322360879-1377695685=:9922 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-length: 1045 What's about #define kzalloc(size, flags) calloc(size, 1) See calloc(3) http://linux.die.net/man/3/calloc Sergei On Wed, 28 Aug 2013, Max Seidenstücker wrote: > As I am trying to touch as few source files as possible I am looking for a > good way to substitute a call to Linux kzalloc(). This function allocates > and zeroes the memory before returning the pointer. So a call to malloc() > and then memset() in eCos is my approach. > > How can a #define be written to do the trick, so I don't need to touch the > source file in this area with #ifdef __ECOS ? > > struct jffs2_inode_info *f = kzalloc(sizeof(*f), GFP_KERNEL); > if (!f) > return -ENOMEM; > > #define kzalloc(x,y) \ > malloc(x); \ > if (HOW_TO_MAKE_SURE_MALLOC_WAS_SUCCESSFUL) { \ > memset(tmp,0,x);\ > } > > Regards > Max Seidenstuecker > > > > -- > View this message in context: http://sourceware-org.1504.n7.nabble.com/Elegant-substitute-for-kzalloc-through-define-tp242405.html > Sent from the Sourceware - ecos-devel mailing list archive at Nabble.com. > ---1463803648-322360879-1377695685=:9922--