From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21246 invoked by alias); 28 Aug 2013 12:23:53 -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 21234 invoked by uid 89); 28 Aug 2013 12:23:53 -0000 Received: from sam.nabble.com (HELO sam.nabble.com) (216.139.236.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 28 Aug 2013 12:23:53 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham version=3.3.2 X-HELO: sam.nabble.com Received: from tom.nabble.com ([192.168.236.105]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VEems-0003XD-DU for ecos-devel@ecos.sourceware.org; Wed, 28 Aug 2013 05:23:50 -0700 Date: Wed, 28 Aug 2013 12:23:00 -0000 From: =?UTF-8?Q?Max_Seidenst=C3=BCcker?= To: ecos-devel@ecos.sourceware.org Message-ID: <1377692630382-242405.post@n7.nabble.com> Subject: Elegant substitute for kzalloc() through #define? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00007.txt.bz2 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.