public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: Sergei Gavrikov <sergei.gavrikov@gmail.com>
To: "Max Seidenstücker" <naturally-aligned@web.de>
Cc: ecos-devel@ecos.sourceware.org
Subject: Re: Elegant substitute for kzalloc() through #define?
Date: Wed, 28 Aug 2013 13:14:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1308281553230.9922@sg-pc.belvok.com> (raw)
In-Reply-To: <1377692630382-242405.post@n7.nabble.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1047 bytes --]

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.
> 

  reply	other threads:[~2013-08-28 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-28 12:23 Max Seidenstücker
2013-08-28 13:14 ` Sergei Gavrikov [this message]
2013-08-30 14:47   ` Max Seidenstuecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1308281553230.9922@sg-pc.belvok.com \
    --to=sergei.gavrikov@gmail.com \
    --cc=ecos-devel@ecos.sourceware.org \
    --cc=naturally-aligned@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).