mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* gcc and aligning
@ 2004-07-10 18:21 Grzegorz Kulewski
  0 siblings, 0 replies; only message in thread
From: Grzegorz Kulewski @ 2004-07-10 18:21 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am trying to experiment with real Linux kernel programming. And I have 
this question.

I have:

struct tree_node {
	struct tree_node *left, *right;
	...
};

struct some1 {
	struct tree_node n;
	...
};

struct some2 {
	struct tree_node n;
	...
};


And I want to write universal function that searches tree of structs some1 
or some2 (but one kind of struct per one tree). Like this:

struct tree_node *search(struct tree_node *root, struct tree_node *key, 
size_t size_of_the_struct);

And in this function I want to compare the _rest_ of some1 or some2 (the 
key) against other nodes. But gcc can insert some alignment between n and 
the rest of some1 or some2. Can I assume that the alignment fill is the 
same in all instances of this struct (for example 0 bytes) and use memcmp 
to compare bytes from begin_of_the_struct + sizeof(struct tree_node) to 
begin_of_the_struct + size_of_the_struct? 

Or is there some better solution?


Thanks,

Grzegorz Kulewski


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-07-10 18:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-10 18:21 gcc and aligning Grzegorz Kulewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®