rev 396 - trunk/modules/Prosist

SVN User <[email protected]> Mon, 19 Apr 2004 17:12:58 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-19 17:12:55 -0400 (Mon, 19 Apr 2004)
New Revision: 396

Modified:
   trunk/modules/Prosist/Prosist.c
Log:
more work on prosist

Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c	2004-04-19 20:53:56 UTC (rev 395)
+++ trunk/modules/Prosist/Prosist.c	2004-04-19 21:12:55 UTC (rev 396)
@@ -98,28 +98,22 @@
 		buf = pr_realloc(buf, buf_size);					\
 } (buf[idx++] = (c)); }
 
-#define ADD_NUM(num)																	\
-	if ((n = apr_snprintf(buf+idx, buf_size-idx, "%d", (num))) == (buf_size-idx)) {		\
-		buf_size += BUF_BLOCK_SIZE;														\
-		buf = pr_realloc(buf, buf_size);												\
-		n = apr_snprintf(buf+idx, buf_size-idx, "%d", (num));							\
-	} idx += n
-
-#define ADD_REF(obj) ADD_NUM(obj_to_id_f(ist, dbrecp, (obj)))
-
-#define ADD_STR(str)																	\
-	if ((n = apr_snprintf(buf+idx, buf_size-idx, "%s", (str))) == (buf_size-idx)) {		\
-		buf_size += BUF_BLOCK_SIZE;														\
-		buf = pr_realloc(buf, buf_size);												\
-		n = apr_snprintf(buf+idx, buf_size-idx, "%s", (str));							\
-	} idx += n
-
 #define ADD_MEM(ptr, len)						\
 	if (idx+len > buf_size) {					\
 			buf_size = idx+len+BUF_BLOCK_SIZE;	\
 			buf = pr_realloc(buf, buf_size);	\
 	} memcpy(buf+idx, ptr, len); idx += len
 
+#define ADD_STR(str) { int slen = (int) strlen(str); ADD_MEM(str, slen); }	
+
+#define ADD_NUM(num)  {									\
+	char numbuf[80];									\
+	apr_snprintf(numbuf, sizeof(numbuf), "%d", (num));	\
+	ADD_STR(numbuf);									\
+}
+
+#define ADD_REF(obj) ADD_NUM(obj_to_id_f(ist, dbrecp, (obj)))
+
 i32_t load_dbm_int(char* key) {
 	return 0;
 }
@@ -165,7 +159,7 @@
 		if_exc_return datum;
 		if (!proxy_obj) bad_proxy = TRUE;
 		else if (proxy_obj != OBJ(NONE) && !is_unclonable(proxy_obj)) {
-			int i, idx=0, n, plen, buf_size;
+			int i, idx=0, plen, buf_size;
 			int added_attr = FALSE;
 			char* buf = pr_malloc(BUF_BLOCK_SIZE);
 
@@ -251,7 +245,7 @@
 		raise_exception(ist, ProsistExc_OBJ, "Database already exists");
 		return;
 	}
-	root_datum = obj_to_datum(ist, dbrecp, dbrecp->root);
+	root_datum = obj_to_datum(ist, dbrecp, dbrecp->root); if_exc_return;
 	if (!root_datum.dptr) {
 		raise_exception(ist, ProsistExc_OBJ, "root object is not storable");
 		return;