public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
* Elegant substitute for kzalloc() through #define?
@ 2013-08-28 12:23 Max Seidenstücker
  2013-08-28 13:14 ` Sergei Gavrikov
  0 siblings, 1 reply; 3+ messages in thread
From: Max Seidenstücker @ 2013-08-28 12:23 UTC (permalink / raw)
  To: ecos-devel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-30 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-28 12:23 Elegant substitute for kzalloc() through #define? Max Seidenstücker
2013-08-28 13:14 ` Sergei Gavrikov
2013-08-30 14:47   ` Max Seidenstuecker

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