Return-Path: owner-postman
Received: from LOCALHOST (LOCALHOST [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id XAA17259 for postgres-redist; Mon, 6 Jun 1994 23:03:58 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199406070603.XAA17259@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host LOCALHOST didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from cs.mtu.edu (cs.mtu.edu [141.219.150.12]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id XAA17249 for <postgres@nobozo.cs.berkeley.edu>; Mon, 6 Jun 1994 23:03:56 -0700
Received: from werner.mtu.edu (werner.cs.mtu.edu) by cs.mtu.edu (4.1/SMI-4.1)
	id AA06822; Tue, 7 Jun 94 02:03:55 EDT
From: aataneja@cs.mtu.edu (Bruce Taneja.)
Message-Id: <9406070603.AA06822@cs.mtu.edu>
Subject: variable size data types..
To: postgres@postgres.Berkeley.EDU
Date: Tue, 7 Jun 1994 02:03:54 -0400 (EDT)
Cc: aataneja@cs.mtu.edu (Bruce Taneja.)
X-Mailer: ELM [version 2.4 PL22]
Content-Type: text
Content-Length: 1515      
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Mon, 06 Jun 94 23:03:57 -0700
Resent-XMts: smtp


Howdy Paul & folks,

Dunno if this is a more of a C question than a postgres question
but since it concerns postgres's variable user defined (array) 
data types, here goes:

example:

	typedef struct {

		int size; 	/* size of this mem glob */
		int n_points;	/* number of points struct nested */
		POINT points[1];/* the first one*/
		int n_circles;	/* the number of circles */
		CIRCLE circles[1]; /* the 1st one*/

		} CIRCLES_N_POINTS;

Next step is to parse my append statement and decide how much space
I require to palloc, once I have determined that and palloced that
space, I start putting the points in : points[0], points[1], points[2]
.. and similarly parsed circles data in circles[0], circles[1], ...

Understandably, the space for these "arrays" is being sliced out of
the palloced glob of memory ..

Now what is the guarantee that C does not write my circles "array"
data over my points "array" data ??? 

The way I see it , C can distinctly identify the CIRCLES_N_POINTS struct
but not the contiguous space following the struct, so both times when
we start to write in locations points[1] and circles[1], the same space
lying right after the struct is going to be used overwriting the previous
data .. or am I (happily) mistaken?..

and, if I am (sadly) right, then what is the solution to having two complex 
variable sized arrays in your defined variable size complex data type?

Perhaps the C gurus or postgres gurus would like to educate the dumb
old me ..
 
thanx for help in advance!
Bruce!

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
