type punning

Brandon Allbery bsa at ncoast.UUCP
Wed Feb 27 02:26:45 AEST 1985


Since we're on the subject, I'm trying to write a program using my own
memory management routines.  Basically, only two kinds of objects are
allocated:  char[] and

	struct _var
		{
		short v_type;
		char *v_name;
		char *v_value;
		struct _var *v_next;
		}

Now, my memory management is to sbrk() when needed, and to put freed
(struct _var)'s onto a free-list; freed strings are appended to char *'s
(v_value) on the free list, and the size of the string is kept in the
then-unused v_type field.

The problem is that I may conceivably use up all process memory (this is
a Xenix system, not vmunix) in strings on the freelist, stored in a
number of unremoveable struct _var's (string sizes near 32767 chars; the
most likely scenario is just ONE struct _var), and need a struct _var
for some reason.  I would like to turn a string into a struct _var.

I've already set up a portability file; by using a set of macros
bsizeof() and word_size, I can get the sizes fairly portably.  But I
don't know how to portably align the struct on whatever boundary it
needs.

Could people on various architectures (VAX/PDP-11, S-1, Honeywell, etc.)
please help me by sending me mail on the necessary alignment needed for
these structures?  With a representative set of architectures, maybe I
could set up some kludgey form of alignof() or similar to make this
possible.

Thanks in advance,
Brandon (bsa at ncoast.UUCP)
-- 
Brandon Allbery, decvax!cwruecmp!ncoast!bsa, ncoast!bsa at case.csnet (etc.)
6504 Chestnut Road Independence, Ohio 44131 +1 216 524 1416 -- CIS 74106,1032
		 -=> Does the Doctor make house calls? <=-



More information about the Comp.lang.c mailing list