rev 271 - in trunk: . include/prothon modules/File modules/Re src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-04 01:37:55 -0500 (Sun, 04 Apr 2004)
New Revision: 271

Modified:
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/modules/File/File.c
   trunk/modules/Re/Re.c
   trunk/src/builtins-core.c
   trunk/src/builtins-list.c
   trunk/src/builtins-string.c
   trunk/src/builtins-tuple.c
   trunk/src/interp.c
   trunk/src/main.c
   trunk/src/memory_mgr.c
   trunk/src/object.c
   trunk/src/prlist.h
   trunk/src/sys.c
Log:
major change to list storage structure for consistancy,
all dataptr types must now have alloc size at beginning of
allocated mem in size_t var,  fixed del list[:]

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/STATUS.txt	2004-04-04 06:37:55 UTC (rev 271)
@@ -52,7 +52,9 @@
 
 Allow obj^attr ?
 
+Super start at function closure object?
 Use self for any obj.func() when obj is proto of self?
+Give new syntax for binding function call to object?
 
 remove \ continuation ?
 

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/include/prothon/prothon.h	2004-04-04 06:37:55 UTC (rev 271)
@@ -529,31 +529,22 @@
 obj_p new_string_n_obj(char* string, size_t n);
 
 // NEW_LIST_OBJ: Create a new list object with a given initial size
-// Only simple ability to create list and append objects are given
-// here.  Use list.dll for complete set of features.
-obj_p new_list_obj(int initial_size);
+obj_p new_list_obj(size_t initial_size);
 
 // CLONE_LIST_OBJ: Create a new list object that's a shallow copy of another
-// Only simple ability to create list and append objects are given
-// here.  Use list.dll for complete set of features.
 obj_p clone_list_obj(isp ist, obj_p list_obj);
 
 // LIST_APPEND: Append object item to existing list object
-// Only simple ability to create list and append objects are given
-// here.  Use list.dll for complete set of features.
 obj_p list_append(isp ist, obj_p list, obj_p item);
 
 // LIST_LEN: Get length of list
-// Only simple ability to create list and append objects are given
-// here.  Use list.dll for complete set of features.
-int list_len(isp ist, obj_p list);
 
+size_t list_len(isp ist, obj_p list);
+
 // LIST_CLEAR: Set length of list to zero
 void list_clear(isp ist, obj_p list);
 
 // LIST_ITEM: Access object i from list
-// Only simple ability to create list and append objects are given
-// here.  Use list.dll for complete set of features.
 obj_p list_item(isp ist, obj_p list, int i);
 
 // LISTn: Convenience list create functions

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/include/prothon/prothon_dll.h	2004-04-04 06:37:55 UTC (rev 271)
@@ -69,7 +69,7 @@
 	void		(*switch_proto_to)(isp ist, obj_p obj, obj_p new_proto);
 	obj_p		(*list_append)(isp ist, obj_p list_obj, obj_p item);
 	obj_p		(*list_item)(isp ist, obj_p list, int i);
-	int			(*list_len)(isp ist, obj_p list);
+	size_t		(*list_len)(isp ist, obj_p list);
 	void		(*list_clear)(isp ist, obj_p list_obj);
 	obj_p		(*list1)(obj_p p1);
 	obj_p		(*list2)(obj_p p1, obj_p p2);
@@ -82,7 +82,7 @@
 	obj_p		(*new_string_obj)(char* string);
 	obj_p		(*new_string_n_obj)(char* string, size_t n);
 	obj_p		(*new_tuple_obj)(int fixed_size);
-	obj_p		(*new_list_obj)(int initial_size);
+	obj_p		(*new_list_obj)(size_t initial_size);
 	obj_p		(*clone_list_obj)(isp ist, obj_p list_obj);
 	obj_p		(*new_func_obj)(isp ist, pr_func* func_ptr, obj_p form_lbl_val_list);
 	obj_p		(*call_func)(isp ist, obj_p self, obj_p func_sym, int parm_cnt, obj_p* lbl_val_arr, obj_p dyn_locals);

Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/modules/File/File.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -635,7 +635,7 @@
 			return NULL;
 		}
 	} else {
-		int i, llen = list_len(ist, parms[1]);
+		int i, llen = (int) list_len(ist, parms[1]);
 		for(i = 0; i < llen; i++) {
 			obj_p item = list_item(ist, parms[1], i);
 			if (!has_proto_QUES(ist, item, OBJ(STRING_PROTO))) {

Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/modules/Re/Re.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -364,7 +364,7 @@
 			default:
 				if (c2 > '0' && c2 <= '9') {
 					char* t;
-					int n;
+					u32_t n;
 					regoff_t sp, ep;
 					if ((c3=*((*p1)++)) >= '0' && c3 <= '9') 
 						n = (c2-'0')*10+(c3-'0');
@@ -523,12 +523,12 @@
 }
 
 DEF(ReMatch, start, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
-	int grp;
+	u32_t grp;
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "start function groupid parameter must be an integer");
 		return NULL;
 	}
-	grp = (int)(parms[1]->data.i64);
+	grp = (u32_t)(parms[1]->data.i64);
 	if (grp < 0 || grp >= list_len(ist, self)/2) {
 		raise_exception(ist, ReException_OBJ, "start function groupid parameter value invalid");
 		return NULL;
@@ -537,12 +537,12 @@
 }
 
 DEF(ReMatch, end, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
-	int grp;
+	u32_t grp;
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "end function groupid parameter must be an integer");
 		return NULL;
 	}
-	grp = (int)(parms[1]->data.i64);
+	grp = (u32_t)(parms[1]->data.i64);
 	if (grp < 0 || grp >= list_len(ist, self)/2) {
 		raise_exception(ist, ReException_OBJ, "end function groupid parameter value invalid");
 		return NULL;
@@ -551,13 +551,13 @@
 }
 
 DEF(ReMatch, span, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
-	int grp;
+	u32_t grp;
 	obj_p res;
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "span function groupid parameter must be an integer");
 		return NULL;
 	}
-	grp = (int)(parms[1]->data.i64);
+	grp = (u32_t)(parms[1]->data.i64);
 	if (grp < 0 || grp >= list_len(ist, self)/2) {
 		raise_exception(ist, ReException_OBJ, "span function groupid parameter value invalid");
 		return NULL;
@@ -592,7 +592,7 @@
 
 DEF( ReMatch, group, list4( sym(ist, "groupid"), OBJ(ZERO_INT),
 							    PARAM_STAR,     sym(ist, "groupids") ) ) {
-	int i, j, llen, ngrps = list_len(ist, self)/2, sp, ep;
+	int i, j, llen, ngrps = ((int)list_len(ist, self))/2, sp, ep;
 	char* orig_s;
 	obj_p orig_s_obj, res;
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
@@ -605,7 +605,7 @@
 		return NULL;
 	}
 	if (parms[3]) {
-		int llen = list_len(ist, parms[3]);
+		int llen = (int)list_len(ist, parms[3]);
 		for (i=0; i < llen; i++) {
 			obj_p item = list_item(ist, parms[3], i);
 			if (!has_proto_QUES(ist, item, OBJ(INT_PROTO))) {
@@ -621,7 +621,7 @@
 	}
 	orig_s_obj = get_attr(ist, self, sym(ist, "string")); if_exc_return NULL;
 	orig_s = strch(orig_s_obj);
-	if (!parms[3] || !(llen = list_len(ist, parms[3]))) {
+	if (!parms[3] || !(llen = (int)list_len(ist, parms[3]))) {
 		j = (int)(parms[1]->data.i64);
 		sp = (int)(list_item(ist, self, j*2  )->data.i64);
 		ep = (int)(list_item(ist, self, j*2+1)->data.i64);
@@ -643,7 +643,7 @@
 }
 
 DEF( ReMatch, groups, list2(sym(ist, "default"), OBJ(NONE))) {
-	int i, ngrps = list_len(ist, self)/2, sp, ep;
+	int i, ngrps = (int)list_len(ist, self)/2, sp, ep;
 	char* orig_s;
 	obj_p orig_s_obj, res = new_tuple_obj(ngrps);
 	orig_s_obj = get_attr(ist, self, sym(ist, "string")); if_exc_return NULL;

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/builtins-core.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -379,7 +379,7 @@
 
 obj_p str_tuple_list(isp ist, obj_p self, char* ldelim, char* rdelim)
 {
-	int i, len=list_len(ist, self);
+	int i, len = (int) list_len(ist, self);
 	char msg[64], *res;
 	obj_p ret_obj;
 
@@ -422,7 +422,7 @@
 obj_p get_sequence_item(isp ist, obj_p self, obj_p slice, int seq_type) {
 	obj_p res = NULL, slice_item1, slice_item2, slice_item3;
 	int i, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
-	int exp_len, self_len, slice_len = list_len(ist, slice);
+	int exp_len, self_len, slice_len = (int) list_len(ist, slice);
 	char* self_str = NULL;
 
 	CHECK_TYPE_EXC(self, OBJ(SEQ_PROTO), "sequence");
@@ -431,7 +431,7 @@
 		self_len = (int) pr_strlen(self);
 		self_str = strch(self);
 	} else
-		self_len = list_len(ist, self);
+		self_len = (int) list_len(ist, self);
 	slice_item1 = list_item(ist, slice,0);
 	if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE)) 
 		slice1_empty=TRUE;

Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/builtins-list.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -69,7 +69,7 @@
 static int seq_len(isp ist, obj_p seq) {
 	if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO)))
 		return (int) strlen(strch(seq));
-	else return list_len(ist, seq);
+	else return (int) list_len(ist, seq);
 }
 
 static obj_p seq_item(isp ist, obj_p seq, int i) {
@@ -93,7 +93,7 @@
 	set_attr(ist, OBJ(OBJECT), sym(ist, "List"), List_OBJ);
 
 	List_OBJ->data_type = OBJ_TYPE_DATAPTR;
-	lstp = List_OBJ->data.ptr = pr_malloc((LIST_OVERHEAD+2) * sizeof(list_t));
+	lstp = List_OBJ->data.ptr = pr_malloc(list_sizeof(2));
 	lstpsize(lstp) = 2;
 	lstplen(lstp)  = 0;
 }
@@ -102,7 +102,7 @@
 	list_p lstp;
 
 	self->data_type = OBJ_TYPE_DATAPTR;
-	lstp = self->data.ptr = pr_malloc((LIST_OVERHEAD+2) * sizeof(list_t));
+	lstp = self->data.ptr = pr_malloc(list_sizeof(2));
 	lstpsize(lstp) = 2;
 	lstplen(lstp)  = 0;
 	return OBJ(NONE);
@@ -117,10 +117,11 @@
 }
 
 DEF(List, __setitem__, FORM_PARAM2) {
+	int j;
 	obj_p slice_item1, slice_item2, slice_item3;
 	obj_p slice = parms[1], value = parms[3];
-	int i, j, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
-	int exp_len, val_len, self_len, slice_len = list_len(ist, slice);
+	i64_t i, new_len, exp_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
+	size_t val_len, self_len, slice_len = list_len(ist, slice);
 	read_unlock(ist, self); write_lock(ist, self);
 	self_len = listlen(self);
 	slice_item1 = list_item(ist, slice,0);
@@ -209,17 +210,18 @@
 			for(i = index1, j=0; i > index2; i += index3, j++)
 				listitem(self, i) = seq_item(ist, value, j);
 	} else {
-		listlen(self) = new_len = index1 + val_len + (self_len - index2);
+		new_len = index1 + (i64_t) val_len + ((i64_t)self_len - index2);
+		listlen(self) = (size_t) new_len;
 		if (new_len+1 > listsize(self)) {
-			listsize(self) = new_len+1;
+			listsize(self) = (size_t) new_len + 1;
 			self->data.ptr = 
-				pr_realloc(self->data.ptr, (listsize(self)+LIST_OVERHEAD)*sizeof(list_t));
+				pr_realloc(self->data.ptr, list_sizeof(listsize(self)));
 		}
 		if (exp_len != val_len && index2 != self_len)
-			memmove( ((list_p)self->data.ptr)+LIST_OVERHEAD+index1+val_len,
-					 ((list_p)self->data.ptr)+LIST_OVERHEAD+index2,
-							 (self_len-index2) * sizeof(list_t) );
-		for(i = index1, j=0; j < val_len; i++, j++)
+			memmove( &(((list_p)self->data.ptr)->item[index1+val_len]),
+					 &(((list_p)self->data.ptr)->item[index2]),
+					 (self_len - (size_t) index2) * sizeof(list_item_t) );
+		for(i = index1, j=0; j < (int) val_len; i++, j++)
 			listitem(self, i) = seq_item(ist, value, j);
 	}
 	write_unlock(ist, self);   read_lock(ist, self); 
@@ -227,11 +229,12 @@
 }
 
 DEF(List, __delitem__, FORM_RPARAM) {
+	int j;
 	obj_p slice_item1, slice_item2, slice_item3;
 	obj_p slice = parms[1];
-	int i, j, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
-	int exp_len, self_len, slice_len = list_len(ist, slice);
-	 read_unlock(ist, self);  write_lock(ist, self);
+	i64_t i, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
+	size_t exp_len, self_len, slice_len = list_len(ist, slice);
+	read_unlock(ist, self);  write_lock(ist, self);
 	self_len = listlen(self);
 	slice_item1 = list_item(ist, slice,0);
 	if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE)) 
@@ -251,9 +254,9 @@
 		}
 		if (slice_len == 1) {
 			if (index1 != self_len-1)
-				memmove( ((list_p)self->data.ptr)+LIST_OVERHEAD+index1,
-					     ((list_p)self->data.ptr)+LIST_OVERHEAD+index1+1,
-							     (self_len-1-index1) * sizeof(list_t) );
+				memmove( &(((list_p)self->data.ptr)->item[index1]),
+					     &(((list_p)self->data.ptr)->item[index1+1]),
+						 (self_len-1 - (size_t)index1) * sizeof(list_item_t) );
 			listlen(self)--;
 			write_unlock(ist, self);   read_lock(ist, self); 
 			return NULL;
@@ -300,28 +303,31 @@
 		if (slice1_empty) index1 = self_len-1;
 		if (slice2_empty) index2 = -1;
 	}
-	exp_len = (index2-index1+(index3-1))/index3;
+	exp_len = (size_t)((index2-index1+(index3-1))/index3);
 	exp_len = max(exp_len, 0);
 	if (index3 != 1) {
 		if (index3 > 0) {
 			for(i = index1, j=0; i < index2; i += index3, j++)
 				if (i != self_len-1)
-					memmove( ((list_p)self->data.ptr)+LIST_OVERHEAD+(i-j),
-							 ((list_p)self->data.ptr)+LIST_OVERHEAD+(i-j)+1,
-									(self_len-1-i) * sizeof(list_t) );
+					memmove( &(((list_p)self->data.ptr)->item[i-j]),
+							 &(((list_p)self->data.ptr)->item[i-j+1]),
+								(self_len - 1 - (size_t)i) * sizeof(list_item_t) );
 		} else {
 			for(i = index1, j=0; i > index2; i += index3, j++)
 				if (i != self_len-1)
-					memmove( ((list_p)self->data.ptr)+LIST_OVERHEAD+i,
-							 ((list_p)self->data.ptr)+LIST_OVERHEAD+i+1,
-									(self_len-1-i) * sizeof(list_t) );
+					memmove( &(((list_p)self->data.ptr)->item[i]),
+							 &(((list_p)self->data.ptr)->item[i+1]),
+								(self_len - 1 - (size_t)i) * sizeof(list_item_t) );
 		}
 	} else {
-		listlen(self) = new_len = index1 + (self_len - index2);
+		new_len = index1 + ((i64_t)self_len - index2);
+		listlen(self) = (size_t) new_len;
 		if (exp_len != 0 && index2 != self_len)
-			memmove( ((list_p)self->data.ptr)+LIST_OVERHEAD+index1,
-					 ((list_p)self->data.ptr)+LIST_OVERHEAD+index2,
-							 (self_len-index2) * sizeof(list_t) );
+			memmove( &(((list_p)self->data.ptr)->item[index1]),
+					 &(((list_p)self->data.ptr)->item[index2]),
+					 (self_len - (size_t)index2) * sizeof(list_item_t) );
+		write_unlock(ist, self);   read_lock(ist, self); 
+		return NULL;
 	}
 	listlen(self) -= exp_len;
 	write_unlock(ist, self);   read_lock(ist, self); 
@@ -332,7 +338,7 @@
 	int i;
 	obj_p res = clone_list_obj(ist, self);
 	if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
-		for(i=0; i < list_len(ist, parms[1]); i++) 
+		for(i=0; i < (int) list_len(ist, parms[1]); i++) 
 			list_append(ist, res, list_item(ist, parms[1], i));
 	else
 		list_append(ist, res, parms[1]);
@@ -341,8 +347,8 @@
 
 DEF(List, __mul__, FORM_RPARAM){
 	obj_p res;
-	list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
-	int i, size, times, len = list_len(ist, self);
+	list_p lstp, selfp = (list_p)(self->data.ptr);
+	int i, size, times, len = (int) list_len(ist, self);
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
 		return NULL;
@@ -352,7 +358,7 @@
 	if(times == 0) return new_list_obj(0);
 	if(times == 1) return self;
 	res = new_object(List_OBJ);
-	lstp = res->data.ptr = pr_malloc((LIST_OVERHEAD+size)*sizeof(list_t));
+	lstp = res->data.ptr = pr_malloc(list_sizeof(size));
 	if(!lstp) {
 		raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for list multiplication");
 		return NULL;
@@ -361,7 +367,7 @@
 	lstpsize(lstp) = size;
 	lstplen(lstp)  = size;
 	for(i=0; i < times; i++)
-		memcpy(lstp+LIST_OVERHEAD+(i*len), selfp, len*sizeof(list_t));
+		memcpy(&(lstp->item[i*len]), selfp->item, len*sizeof(list_item_t));
 	return res;
 }
 
@@ -371,7 +377,7 @@
 	lstp = self->data.ptr;
 	if(lstplen(lstp) == lstpsize(lstp)) {
 		lstpsize(lstp) *= LIST_GROWTH_FACTOR;
-		lstp = pr_realloc(lstp, (LIST_OVERHEAD+lstpsize(lstp)) * sizeof(list_t));
+		lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
 		self->data.ptr = lstp;
 	}
 	listitem(self, listlen(self)++) = parms[1];
@@ -381,7 +387,7 @@
 
 DEF(List, extend_BANG, FORM_RPARAM) {
 	list_p selfp, otherp;
-	int self_len, other_len;
+	size_t self_len, other_len;
 	read_unlock(ist, self);  write_lock(ist, self);
 	if (!has_proto_QUES(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto_QUES(ist, parms[1], List_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "extend parameter must be a tuple or list");
@@ -393,17 +399,18 @@
 	other_len = lstplen(otherp);
 	if(self_len+other_len > lstpsize(selfp)) {
 		lstpsize(selfp) = (self_len+other_len) * LIST_GROWTH_FACTOR;
-		selfp = pr_realloc(selfp, (LIST_OVERHEAD+lstpsize(selfp)) * sizeof(list_t));
+		selfp = pr_realloc(selfp, list_sizeof(lstpsize(selfp)));
 		self->data.ptr = selfp;
 	}
-	memcpy( selfp+LIST_OVERHEAD+self_len, otherp+LIST_OVERHEAD, other_len*sizeof(list_t));
+	memcpy( selfp->item+self_len, otherp->item, other_len*sizeof(list_item_t));
 	lstplen(selfp) = self_len+other_len;
 	write_unlock(ist, self);   read_lock(ist, self); 
 	return self;
 }
 
 DEF(List, insert_BANG, FORM_PARAM2) {
-	int index, self_len;
+	i64_t index;
+	size_t self_len;
 	list_p selfp;
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "index (i) parameter must be an integer");
@@ -420,12 +427,12 @@
 	}
 	if(lstplen(selfp) == lstpsize(selfp)) {
 		lstpsize(selfp) *= LIST_GROWTH_FACTOR;
-		selfp = pr_realloc(selfp, (LIST_OVERHEAD+lstpsize(selfp))*sizeof(list_t));
+		selfp = pr_realloc(selfp, list_sizeof(lstpsize(selfp)));
 		self->data.ptr = selfp;
 	}
 	if (index < self_len)
-		memmove( selfp+LIST_OVERHEAD+index+1, selfp+LIST_OVERHEAD+index, 
-										 (self_len-index)*sizeof(list_t) ); 
+		memmove( selfp->item+index+1, selfp->item+index, 
+				  (self_len - (size_t)index) * sizeof(list_item_t) ); 
 	listitem(self, index) = parms[3];
 	lstplen(selfp)++;
 	write_unlock(ist, self);   read_lock(ist, self); 
@@ -433,7 +440,8 @@
 }
 
 DEF(List, remove_BANG, FORM_RPARAM) {
-	int i, self_len;
+	i64_t i;
+	size_t self_len;
 	list_p selfp;
 	read_unlock(ist, self);  write_lock(ist, self);
 	selfp    = self->data.ptr;
@@ -448,15 +456,16 @@
 		return NULL;
 	}
 	if (i < self_len-1)
-		memmove( selfp+LIST_OVERHEAD+i, selfp+LIST_OVERHEAD+i+1, 
-								   (self_len-1-i)*sizeof(list_t) ); 
+		memmove( selfp->item+i, selfp->item+i+1, 
+		        (self_len - 1 - (size_t)i) * sizeof(list_item_t) ); 
 	lstplen(selfp)--;
 	write_unlock(ist, self);   read_lock(ist, self); 
 	return self;
 }
 
 DEF(List, pop_BANG, list2(SYM(RPARAM),OBJ(NONE))) {
-	int index, self_len;
+	i64_t index;
+	size_t self_len;
 	list_p selfp;
 	obj_p res;
 	if (parms[1] != OBJ(NONE) && !has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
@@ -477,23 +486,24 @@
 	}
 	res = listitem(self, index);
 	if (index < self_len-1)
-		memmove( selfp+LIST_OVERHEAD+index, selfp+LIST_OVERHEAD+index+1, 
-									   (self_len-1-index)*sizeof(list_t) ); 
+		memmove( selfp->item+index, selfp->item+index+1, 
+				 (self_len - 1 - (size_t)index) * sizeof(list_item_t) ); 
 	lstplen(selfp)--;
 	write_unlock(ist, self);   read_lock(ist, self); 
 	return res;
 }
 
 DEF(List, reverse_BANG, NULL) {
-	int self_len;
-	list_p selfp, p1, p2;
+	size_t self_len;
+	list_p selfp;
+	list_item_t *p1, *p2;
 	read_unlock(ist, self);  write_lock(ist, self);
 	selfp    = self->data.ptr;
 	self_len = lstplen(selfp);
-	p1 = selfp+LIST_OVERHEAD;
-	p2 = selfp+LIST_OVERHEAD+self_len-1;
+	p1 = selfp->item;
+	p2 = selfp->item+self_len-1;
 	while(p1<p2) {
-		list_t tmp = *p2;
+		list_item_t tmp = *p2;
 		*p2 = *p1;
 		*p1 = tmp;
 		p1++; p2--;

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/builtins-string.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -210,7 +210,7 @@
 		return NULL;
 	}
 	list = parms[1];
-	llen = list_len(ist, parms[1]);
+	llen = (int) list_len(ist, parms[1]);
 	if (!llen) return new_string_obj("");
 	str_list = new_list_obj(llen);
 	self_str = strch(self);

Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/builtins-tuple.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -78,7 +78,7 @@
 	set_attr(ist, OBJ(OBJECT), sym(ist, "Tuple"), Tuple_OBJ);
 
 	Tuple_OBJ->data_type = OBJ_TYPE_DATAPTR;
-	lstp = Tuple_OBJ->data.ptr = pr_malloc((LIST_OVERHEAD+2) * sizeof(list_t));
+	lstp = Tuple_OBJ->data.ptr = pr_malloc(list_sizeof(2));
 	lstpsize(lstp) = 2;
 	lstplen(lstp)  = 0;
 }
@@ -87,7 +87,7 @@
 	list_p lstp;
 
 	self->data_type = OBJ_TYPE_DATAPTR;
-	lstp = self->data.ptr = pr_malloc((LIST_OVERHEAD+2) * sizeof(list_t));
+	lstp = self->data.ptr = pr_malloc(list_sizeof(2));
 	lstpsize(lstp) = 2;
 	lstplen(lstp)  = 0;
 	return OBJ(NONE);
@@ -123,9 +123,9 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "sequence can only be compared to a sequence");
 		return NULL;
 	}
-	llen = list_len(ist, self);
+	llen = (int) list_len(ist, self);
 	tgt_list = parms[1];
-	tlen = list_len(ist, tgt_list);
+	tlen = (int) list_len(ist, tgt_list);
 	mlen = min(llen, tlen);
 	for(i=0; i < mlen; i++) {
 		self_item = list_item(ist, self, i);
@@ -143,9 +143,9 @@
 	int i, llen, tlen;
 	obj_p self_item, tgt_item, tgt_list, false_obj = OBJ(PR_FALSE);
 	if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO))) return false_obj;
-	llen = list_len(ist, self);
+	llen = (int) list_len(ist, self);
 	tgt_list = parms[1];
-	tlen = list_len(ist, tgt_list);
+	tlen = (int) list_len(ist, tgt_list);
 	if (llen != tlen)  return false_obj;
 	for(i=0; i < llen; i++) {
 		self_item = list_item(ist, self, i);
@@ -158,7 +158,7 @@
 }
 
 DEF(Tuple, __rin__QUES, FORM_RPARAM) { 
-	int i, llen = list_len(ist, self);
+	int i, llen = (int) list_len(ist, self);
 	obj_p item, tgt = parms[1];
 	for(i=0; i < llen; i++) {
 		item = list_item(ist, self, i);
@@ -170,7 +170,7 @@
 }
 
 DEF(Tuple, __rnotin__QUES, FORM_RPARAM) { 
-	int i, llen = list_len(ist, self);
+	int i, llen = (int) list_len(ist, self);
 	obj_p item, tgt = parms[1];
 	for(i=0; i < llen; i++) {
 		item = list_item(ist, self, i);
@@ -185,7 +185,7 @@
 	int i;
 	obj_p res = clone_list_obj(ist, self);
 	if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
-		for(i=0; i < list_len(ist, parms[1]); i++) 
+		for(i=0; i < (int) list_len(ist, parms[1]); i++) 
 			list_append(ist, res, list_item(ist, parms[1], i));
 	else
 		list_append(ist, res, parms[1]);
@@ -195,8 +195,8 @@
 
 DEF(Tuple, __mul__, FORM_RPARAM){
 	obj_p res;
-	list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
-	int i, size, times, len = list_len(ist, self);
+	list_p lstp, selfp = (list_p)(self->data.ptr);
+	int i, size, times, len = (int) list_len(ist, self);
 	if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
 		return NULL;
@@ -210,7 +210,7 @@
 	}
 	if(times == 1) return self;
 	res = new_object(OBJ(TUPLE_PROTO));
-	lstp = res->data.ptr = pr_malloc((LIST_OVERHEAD+size)*sizeof(list_t));
+	lstp = res->data.ptr = pr_malloc(list_sizeof(size));
 	if(!lstp) {
 		raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for tuple multiplication");
 		return NULL;
@@ -219,7 +219,7 @@
 	lstpsize(lstp) = size;
 	lstplen(lstp)  = size;
 	for(i=0; i < times; i++)
-		memcpy(lstp+LIST_OVERHEAD+(i*len), selfp, len*sizeof(list_t));
+		memcpy(lstp->item+(i*len), selfp->item, len*sizeof(list_item_t));
 	return res;
 }
 
@@ -228,7 +228,7 @@
 }
 
 DEF(Tuple, min, NULL) { 
-	int i, llen = list_len(ist, self);
+	int i, llen = (int) list_len(ist, self);
 	obj_p min_item, cmp_obj;
 	if (llen == 0) return OBJ(NONE);
 	if (llen == 1) return list_item(ist, self, 0);
@@ -243,7 +243,7 @@
 }
 
 DEF(Tuple, max, NULL) { 
-	int i, llen = list_len(ist, self);
+	int i, llen = (int) list_len(ist, self);
 	obj_p max_item, cmp_obj;
 	if (llen == 0) return OBJ(NONE);
 	if (llen == 1) return list_item(ist, self, 0);
@@ -258,7 +258,7 @@
 }
 
 DEF(Tuple, count, FORM_RPARAM) { 
-	int i, cnt=0, llen = list_len(ist, self);
+	int i, cnt=0, llen = (int) list_len(ist, self);
 	for (i=0; i < llen; i++) {
 		if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE))
 			cnt++;
@@ -268,7 +268,7 @@
 }
 
 DEF(Tuple, index, FORM_RPARAM) { 
-	int i, llen = list_len(ist, self);
+	int i, llen = (int) list_len(ist, self);
 	for (i=0; i < llen; i++) {
 		if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE))
 			return new_int_obj(i);

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/interp.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -155,7 +155,7 @@
 	obj_p form_params, label, value;
 	memset(fparam_proc_state, 0, sizeof(fparam_proc_state_t));
 	if ((form_params = get_attr(ist, func_obj, SYM(__FPARAMS__)))) {
-		int i, j, pstate = 0, fcnt = list_len(ist, form_params);
+		int i, j, pstate = 0, fcnt = (int) list_len(ist, form_params);
 		fparam_proc_state->lbl_val_list  = new_clist(fcnt);
 		for (i=0, j=0; i < fcnt; i+=2) {
 			label = list_item(ist, form_params, i);
@@ -373,7 +373,7 @@
 	} else
 		dest_module = NULL;
 
-	llen = list_len(ist, path_list);
+	llen = (int) list_len(ist, path_list);
 	pkg_path[0] = 0;
 
 	for (i = 0; i < llen; i++) {
@@ -727,8 +727,8 @@
 				obj_p fparams_obj = new_list_obj(fparams_len);
 				fr_sp -= fparams_len+2;
 				assert(sizeof(list_t) == sizeof(obj_p));
-				memcpy( ((list_p)(obj_data_p(fparams_obj)))+LIST_OVERHEAD, 
-						fr_stack+fr_sp+2, fparams_len*sizeof(obj_p) );
+				memcpy( ((list_p)(obj_data_p(fparams_obj)))->item, 
+						fr_stack+fr_sp+2, fparams_len*sizeof(list_item_t) );
 				listlen(fparams_obj) = fparams_len;
 				set_attr(ist, func,    SYM(__FPARAMS__),    fparams_obj);
 				set_attr(ist, func,    SYM(__GLOBALS__), frame->globals);
@@ -757,8 +757,8 @@
 				obj_p func = fr_data(2);
 				obj_p fparams_obj = new_list_obj(fparams_len);
 				fr_sp -= fparams_len;
-				memcpy( ((list_p)(obj_data_p(fparams_obj)))+LIST_OVERHEAD, 
-						fr_stack+fr_sp, fparams_len*sizeof(obj_p) );
+				memcpy( ((list_p)(obj_data_p(fparams_obj)))->item, 
+						fr_stack+fr_sp, fparams_len*sizeof(list_item_t) );
 				set_attr(ist, func,    SYM(__FPARAMS__),    fparams_obj);
 				set_attr(ist, func,    SYM(__GLOBALS__), frame->globals);
 				set_attr(ist, func, SYM(__SYN_LOCALS__),  frame->locals);
@@ -1251,7 +1251,7 @@
 	printf("\nUncaught exception:\n");
 
 	if ((fstk_obj = get_attr(ist, orig_excobj, sym(ist, "frame_stack")))) {
-		for (i = list_len(ist, fstk_obj) - 3; i >= 0; i -= 3) {
+		for (i = (int) list_len(ist, fstk_obj) - 3; i >= 0; i -= 3) {
 			printf( "--- File: %s, line: "LONG_LONG_FMT", char: "LONG_LONG_FMT"\n",
 				strch(list_item(ist, fstk_obj, i  )), 
 				*((LONG_LONG_CAST *)obj_data_p(list_item(ist, fstk_obj, i+1))), 
@@ -1260,7 +1260,7 @@
 	}
 
 	if (bl) {
-		for (i = list_len(ist, bl) - 1; i >= 0; i--){
+		for (i = (int) list_len(ist, bl) - 1; i >= 0; i--){
 			obj_p exc = list_item(ist, bl, i);
 
 			if (exc && exc != OBJ(EXCEPTION) && has_proto_QUES(ist, exc, OBJ(EXCEPTION))) {
@@ -1596,7 +1596,7 @@
 	if (code->file_path)
 		fprintf(fout,"file_path: %s\n\n",  code->file_path);
 	if (func && (lbl_value_list = get_attr(ist, func, SYM(__FPARAMS__)))) {
-		int llen = list_len(ist, lbl_value_list);
+		int llen = (int) list_len(ist, lbl_value_list);
 		if (llen) fprintf(fout,"\nFormal Params:\n");
 		for (i=0; i < llen; i += 2) {
 			char *lbl_str = NULL, *val_str = NULL;

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/main.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -229,7 +229,7 @@
 	threads = get_attr(ist, sys_argv_obj, sym(ist, "threads"));
 	if (threads) {
 		int i;
-		for (i = 0; i < list_len(ist, threads); i++)
+		for (i = 0; i < (int) list_len(ist, threads); i++)
 			new_thread_obj((apr_thread_start_t)main_thread, list_item(ist, threads, i));
 	}
 

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/memory_mgr.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -211,7 +211,7 @@
 						strch(get_attr(ist, ist->exception_obj, SYM(__DOC__))));
 					ist->exception_obj = 0;
 				} else if (obj_list) {
-					int i, llen = list_len(ist, obj_list);
+					int i, llen = (int) list_len(ist, obj_list);
 					for(i=0; i < llen; i++) {
 						obj_p val = listitem(obj_list, i);
 						if (val > min_obj && val != obj && !val->scanned) {

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/object.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -239,6 +239,25 @@
 	return obj;
 }
 
+//********************************* clone_object *******************************
+obj_p clone_object(isp ist, obj_p obj){
+	obj_p clone = new_object(NULL);
+	read_lock(ist, obj);
+	memcpy(clone, obj, sizeof(obj_t) - sizeof(obj->next_obj));
+	clone->archived			= FALSE;
+	clone->long_wrlock		= FALSE;
+	clone->rdlock_cnt		= 0;
+	clone->wrlock_req_cnt	= 0;
+	clone->wrlock			= 0;
+	clone->del_locked		= TRUE;
+	if (obj->has_attrs)
+		pr_free(obj->attr_proto.attrs);
+	if (obj->data_type == OBJ_TYPE_DATAPTR)
+		pr_free(obj->data.ptr);
+	read_unlock(ist, obj);
+	return clone;
+}
+
 //********************************* free_object *******************************
 void free_object(obj_p obj){
 	if (obj->has_attrs)
@@ -291,7 +310,7 @@
 		if (proto && has_proto_QUES(ist, exc_obj, proto))
 			return exc_obj;
 		if (proto_list)
-			for (i=0; i < list_len(ist, proto_list); i++){
+			for (i=0; i < (int) list_len(ist, proto_list); i++){
 				if (has_proto_QUES(ist, exc_obj, list_item(ist, proto_list, i)))
 					return exc_obj;
 			}
@@ -914,10 +933,10 @@
 
 
 //********************************* new_list_obj ******************************
-obj_p new_list_obj(int initial_size){
+obj_p new_list_obj(size_t initial_size){
 	obj_p list_obj = new_object(OBJ(LIST_PROTO));
 	list_p lstp = list_obj->data.ptr = 
-		      pr_malloc((LIST_OVERHEAD+max(initial_size,2)) * sizeof(list_t));
+		      pr_malloc(list_sizeof(max(initial_size,2)));
 	list_obj->data_type = OBJ_TYPE_DATAPTR;
 	lstpsize(lstp) = max(initial_size,2);
 	lstplen(lstp)  = 0;
@@ -929,17 +948,17 @@
 	obj_p res;
 	read_lock(ist, list_obj);
 	res = new_list_obj(listlen(list_obj));
-	memcpy( (list_p)(res->data.ptr)+LIST_OVERHEAD, 
-		    (list_p)(list_obj->data.ptr)+LIST_OVERHEAD, 
-			 listlen(list_obj) * sizeof(list_t) );
+	memcpy( ((list_p)(res->data.ptr))->item, 
+		    ((list_p)(list_obj->data.ptr))->item, 
+			 listlen(list_obj) * sizeof(list_item_t) );
 	listlen(res) = listlen(list_obj);
 	read_unlock(ist, list_obj);
 	return res;
 }
 
 //********************************* list_len **********************************
-int list_len(isp ist, obj_p list_obj){
-	int len;
+size_t list_len(isp ist, obj_p list_obj){
+	size_t len;
 	read_lock(ist, list_obj);
 	len = listlen(list_obj);
 	read_unlock(ist, list_obj);
@@ -969,7 +988,7 @@
 	lstp = list_obj->data.ptr;
 	if(lstplen(lstp) == lstpsize(lstp)) {
 		lstpsize(lstp) *= LIST_GROWTH_FACTOR;
-		lstp = pr_realloc(lstp, (LIST_OVERHEAD+lstpsize(lstp)) * sizeof(list_t));
+		lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
 		list_obj->data.ptr = lstp;
 	}
 	listitem(list_obj, listlen(list_obj)++) = item;
@@ -983,7 +1002,7 @@
 	lstp = list_obj->data.ptr;
 	if(lstplen(lstp) == lstpsize(lstp)) {
 		lstpsize(lstp) *= LIST_GROWTH_FACTOR;
-		lstp = pr_realloc(lstp, (LIST_OVERHEAD+lstpsize(lstp)) * sizeof(list_t));
+		lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
 		list_obj->data.ptr = lstp;
 	}
 	listitem(list_obj, listlen(list_obj)++) = item;
@@ -1180,7 +1199,7 @@
 	int i, len;
 	char* res;
 	read_lock(ist, OBJ(SYMBOLS));
-	len = list_len(ist, OBJ(SYMBOLS));
+	len = (int) list_len(ist, OBJ(SYMBOLS));
 	for(i=0; i < len; i++)
 		if (list_item(ist, OBJ(SYMBOLS),i)->data.key == key)
 			break;

Modified: trunk/src/prlist.h
===================================================================
--- trunk/src/prlist.h	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/prlist.h	2004-04-04 06:37:55 UTC (rev 271)
@@ -56,20 +56,28 @@
 #define DEFAULT_INITIAL_LIST_SIZE	8
 #define LIST_GROWTH_FACTOR			2
 
-#define LIST_SIZE_INDEX		0
-#define LIST_LEN_INDEX		1  
-#define LIST_OVERHEAD		2
+#define list_sizeof(n)	(sizeof(list_hdr_t)+((n)*sizeof(list_item_t)))
 
+typedef struct {
+	size_t	size;
+	size_t	len;
+} list_hdr_t;
+
 typedef union {
 	int     num;
 	obj_p	item;
+} list_item_t;
+
+typedef struct {
+	list_hdr_t  hdr;
+	list_item_t	item[];
 } list_t;
 
 typedef list_t* list_p;
 
-#define lstpsize(list_ptr)		(((list_p)(list_ptr))[LIST_SIZE_INDEX].num)
-#define lstplen(list_ptr)		(((list_p)(list_ptr))[LIST_LEN_INDEX].num)
-#define lstpitem(list_ptr,i)	(((list_p)(list_ptr))[LIST_OVERHEAD+(i)].item)
+#define lstpsize(list_ptr)		(((list_p)(list_ptr))->hdr.size)
+#define lstplen(list_ptr)		(((list_p)(list_ptr))->hdr.len)
+#define lstpitem(list_ptr,i)	(((list_p)(list_ptr))->item[i].item)
 
 #define listsize(list_obj)		lstpsize((list_obj)->data.ptr)
 #define listlen(list_obj)		 lstplen((list_obj)->data.ptr)

Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c	2004-04-04 02:23:17 UTC (rev 270)
+++ trunk/src/sys.c	2004-04-04 06:37:55 UTC (rev 271)
@@ -109,7 +109,7 @@
 }
 
 static void add_path(isp ist, obj_p list, char* path) {
-	int i, llen = list_len(ist, list);
+	int i, llen = (int) list_len(ist, list);
 	char full_path[1024];
 
 #ifdef WIN32
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.