Changed the name of the recently added public function

* xpath.c include/libxml/xpath.h runsuite.c:
  Changed the name of the recently added public function
  xmlXPathContextSetObjectCache() to
  xmlXPathContextSetCache(); so a more generic one, in
  case we decide to cache more things than only XPath
  objects.
diff --git a/ChangeLog b/ChangeLog
index f16384e..52fdb38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed May 31 14:33:00 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+	* xpath.c include/libxml/xpath.h runsuite.c:
+	  Changed the name of the recently added public function
+	  xmlXPathContextSetObjectCache() to
+	  xmlXPathContextSetCache(); so a more generic one, in
+	  case we decide to cache more things than only XPath
+	  objects.
+
 Tue May 30 21:36:16 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
 
 	* xpath.c: Optimized xmlXPathNodeCollectAndTest() and
diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h
index 70edd9d..febbf78 100644
--- a/include/libxml/xpath.h
+++ b/include/libxml/xpath.h
@@ -343,8 +343,9 @@
     /* dictionnary */
     xmlDictPtr dict;			/* dictionnary if any */
 
-    int flags;				/* flags to control compilation */
-    void *objCache; /* Cache for reusal of XPath objects. */
+    int flags;				/* flags to control compilation */

+    /* Cache for reusal of XPath objects */
+    void *cache;
 };
 
 /*
@@ -490,10 +491,10 @@
 XMLPUBFUN void XMLCALL
 		    xmlXPathFreeContext		(xmlXPathContextPtr ctxt);
 XMLPUBFUN int XMLCALL
-		    xmlXPathContextSetObjectCache(xmlXPathContextPtr ctxt,
-						 int active,
-						 int maxNumberPerSlot,
-						 int options);
+		    xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
+				            int active,
+					    int value,
+					    int options);
 /**
  * Evaluation functions.
  */
diff --git a/runsuite.c b/runsuite.c
index 9905feb..744875c 100644
--- a/runsuite.c
+++ b/runsuite.c
@@ -229,12 +229,12 @@
     * Deactivate the cache if created; otherwise we have to create/free it
     * for every test, since it will confuse the memory leak detection.
     * Note that normally this need not be done, since the cache is not
-    * created until set explicitely with xmlXPathContextSetObjectCache();
+    * created until set explicitely with xmlXPathContextSetCache();
     * but for test purposes it is sometimes usefull to activate the
     * cache by default for the whole library.
     */
-    if (ctxtXPath->objCache != NULL)
-	xmlXPathContextSetObjectCache(ctxtXPath, 0, -1, 0);
+    if (ctxtXPath->cache != NULL)
+	xmlXPathContextSetCache(ctxtXPath, 0, -1, 0);
     /* used as default nanemspace in xstc tests */
     xmlXPathRegisterNs(ctxtXPath, BAD_CAST "ts", BAD_CAST "TestSuite");
     xmlXPathRegisterNs(ctxtXPath, BAD_CAST "xlink",
diff --git a/xpath.c b/xpath.c
index 2d14497..4e373c0 100644
--- a/xpath.c
+++ b/xpath.c
@@ -812,11 +812,11 @@
 
 /* #define XP_DEFAULT_CACHE_ON */
 
-#define XP_HAS_CACHE(c) ((c != NULL) && ((c)->objCache != NULL))
+#define XP_HAS_CACHE(c) ((c != NULL) && ((c)->cache != NULL))
 
-typedef struct _xmlXPathObjectCache xmlXPathObjectCache;
-typedef xmlXPathObjectCache *xmlXPathObjectCachePtr;
-struct _xmlXPathObjectCache {
+typedef struct _xmlXPathContextCache xmlXPathContextCache;
+typedef xmlXPathContextCache *xmlXPathContextCachePtr;
+struct _xmlXPathContextCache {
     xmlPointerListPtr nodesetObjs;  /* contains xmlXPathObjectPtr */
     xmlPointerListPtr stringObjs;   /* contains xmlXPathObjectPtr */
     xmlPointerListPtr booleanObjs;  /* contains xmlXPathObjectPtr */
@@ -1350,9 +1350,9 @@
 xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
 {
     if (ctxt != NULL) {
-	if (ctxt->objCache != NULL) {
-	    xmlXPathObjectCachePtr cache =
-		(xmlXPathObjectCachePtr) ctxt->objCache;
+	if (ctxt->cache != NULL) {
+	    xmlXPathContextCachePtr cache =
+		(xmlXPathContextCachePtr) ctxt->cache;
 
 	    cache->dbgCachedAll = 0;
 	    cache->dbgCachedNodeset = 0;
@@ -1425,9 +1425,9 @@
     int isCached = 0;
 
     if (ctxt != NULL) {
-	if (ctxt->objCache != NULL) {
-	    xmlXPathObjectCachePtr cache =
-		(xmlXPathObjectCachePtr) ctxt->objCache;
+	if (ctxt->cache != NULL) {
+	    xmlXPathContextCachePtr cache =
+		(xmlXPathContextCachePtr) ctxt->cache;
 	    
 	    isCached = 1;
 	    
@@ -1579,9 +1579,9 @@
     int isCached = 0;
 
     if (ctxt != NULL) {
-	if (ctxt->objCache != NULL) {
-	    xmlXPathObjectCachePtr cache =
-		(xmlXPathObjectCachePtr) ctxt->objCache;
+	if (ctxt->cache != NULL) {
+	    xmlXPathContextCachePtr cache =
+		(xmlXPathContextCachePtr) ctxt->cache;
 
 	    isCached = 1;	    
 	    
@@ -1683,9 +1683,9 @@
     printf("# XPath object usage:\n");
 
     if (ctxt != NULL) {
-	if (ctxt->objCache != NULL) {
-	    xmlXPathObjectCachePtr cache =
-		(xmlXPathObjectCachePtr) ctxt->objCache;
+	if (ctxt->cache != NULL) {
+	    xmlXPathContextCachePtr cache =
+		(xmlXPathContextCachePtr) ctxt->cache;
 
 	    reAll = cache->dbgReusedAll;
 	    reqAll += reAll;
@@ -1779,23 +1779,23 @@
  ************************************************************************/
 
 /**
- * xmlXPathNewObjectCache:
+ * xmlXPathNewCache:
  *
  * Create a new object cache
  *
- * Returns the xmlXPathObjectCahce just allocated.
+ * Returns the xmlXPathCache just allocated.
  */
-static xmlXPathObjectCachePtr
-xmlXPathNewObjectCache(void)
+static xmlXPathContextCachePtr
+xmlXPathNewCache(void)
 {
-    xmlXPathObjectCachePtr ret;
+    xmlXPathContextCachePtr ret;
 
-    ret = (xmlXPathObjectCachePtr) xmlMalloc(sizeof(xmlXPathObjectCache));
+    ret = (xmlXPathContextCachePtr) xmlMalloc(sizeof(xmlXPathContextCache));
     if (ret == NULL) {
         xmlXPathErrMemory(NULL, "creating object cache\n");
 	return(NULL);
     }
-    memset(ret, 0 , (size_t) sizeof(xmlXPathObjectCache));
+    memset(ret, 0 , (size_t) sizeof(xmlXPathContextCache));
     ret->maxNodeset = 100;
     ret->maxString = 100;
     ret->maxBoolean = 100;
@@ -1805,7 +1805,7 @@
 }
 
 static void
-xmlXPathFreeObjectCacheList(xmlPointerListPtr list)
+xmlXPathCacheFreeObjectList(xmlPointerListPtr list)
 {
     int i;
     xmlXPathObjectPtr obj;
@@ -1833,67 +1833,74 @@
 }
 
 static void
-xmlXPathFreeObjectCache(xmlXPathObjectCachePtr cache)
+xmlXPathFreeCache(xmlXPathContextCachePtr cache)
 {
     if (cache == NULL)
 	return;
     if (cache->nodesetObjs)
-	xmlXPathFreeObjectCacheList(cache->nodesetObjs);
+	xmlXPathCacheFreeObjectList(cache->nodesetObjs);
     if (cache->stringObjs)
-	xmlXPathFreeObjectCacheList(cache->stringObjs);
+	xmlXPathCacheFreeObjectList(cache->stringObjs);
     if (cache->booleanObjs)
-	xmlXPathFreeObjectCacheList(cache->booleanObjs);
+	xmlXPathCacheFreeObjectList(cache->booleanObjs);
     if (cache->numberObjs)
-	xmlXPathFreeObjectCacheList(cache->numberObjs);
+	xmlXPathCacheFreeObjectList(cache->numberObjs);
     if (cache->miscObjs)
-	xmlXPathFreeObjectCacheList(cache->miscObjs);    
+	xmlXPathCacheFreeObjectList(cache->miscObjs);    
     xmlFree(cache);
 }
 
 /**
- * xmlXPathContextSetObjectCache:
+ * xmlXPathContextSetCache:
  *
  * @ctxt:  the XPath context
  * @active: enables/disables (creates/frees) the cache
- * @maxNumberPerSlot: the maximum number of XPath objects to be cached per slot
- * @options: currently not used
+ * @value: a value with semantics dependant on @options 
+ * @options: options (currently only the value 0 is used)
  *
  * Creates/frees an object cache on the XPath context.
  * If activates XPath objects (xmlXPathObject) will be cached internally
- * to be reused.
- * @maxNumberPerSlot is the maximum number of XPath objects to be cached per
- * slot. There are 5 slots for: node-set, string, number, boolean, and
- * misc objects. Use <0 for the default number (100).
+ * to be reused.

+ * @options:

+ *   0: This will set the XPath object caching:

+ *      @value:

+ *        This will set the maximum number of XPath objects

+ *        to be cached per slot
+ *        There are 5 slots for: node-set, string, number, boolean, and
+ *        misc objects. Use <0 for the default number (100).

+ *   Other values for @options have currently no effect.
  *
  * Returns 0 if the setting succeeded, and -1 on API or internal errors.
  */
 int
-xmlXPathContextSetObjectCache(xmlXPathContextPtr ctxt,
-			      int active,
-			      int maxNumberPerSlot,
-			      int options ATTRIBUTE_UNUSED)
+xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
+			int active,
+			int value,
+			int options)
 {
     if (ctxt == NULL)
 	return(-1);
     if (active) {
-	xmlXPathObjectCachePtr cache;
+	xmlXPathContextCachePtr cache;
 	
-	if (ctxt->objCache == NULL) {
-	    ctxt->objCache = xmlXPathNewObjectCache();
-	    if (ctxt->objCache == NULL)
+	if (ctxt->cache == NULL) {
+	    ctxt->cache = xmlXPathNewCache();
+	    if (ctxt->cache == NULL)
 		return(-1);
 	}
-	cache = (xmlXPathObjectCachePtr) ctxt->objCache;
-	if (maxNumberPerSlot < 0)
-	    maxNumberPerSlot = 100;
-	cache->maxNodeset = maxNumberPerSlot;
-	cache->maxString = maxNumberPerSlot;
-	cache->maxNumber = maxNumberPerSlot;
-	cache->maxBoolean = maxNumberPerSlot;
-	cache->maxMisc = maxNumberPerSlot;
-    } else if (ctxt->objCache != NULL) {
-	xmlXPathFreeObjectCache((xmlXPathObjectCachePtr) ctxt->objCache);
-	ctxt->objCache = NULL;
+	cache = (xmlXPathContextCachePtr) ctxt->cache;

+	if (options == 0) {
+	    if (value < 0)
+		value = 100;
+	    cache->maxNodeset = value;
+	    cache->maxString = value;
+	    cache->maxNumber = value;
+	    cache->maxBoolean = value;
+	    cache->maxMisc = value;

+	}
+    } else if (ctxt->cache != NULL) {
+	xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
+	ctxt->cache = NULL;
     }
     return(0);
 }
@@ -1911,9 +1918,9 @@
 static xmlXPathObjectPtr
 xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
 {    
-    if ((ctxt != NULL) && (ctxt->objCache != NULL)) {
-	xmlXPathObjectCachePtr cache =
-	    (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache != NULL)) {
+	xmlXPathContextCachePtr cache =
+	    (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->miscObjs != NULL) &&
 	    (cache->miscObjs->number != 0))
@@ -1948,8 +1955,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
 {    
-    if ((ctxt != NULL) && (ctxt->objCache != NULL)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache != NULL)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->stringObjs != NULL) &&
 	    (cache->stringObjs->number != 0))
@@ -2000,8 +2007,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
 {
-    if ((ctxt != NULL) && (ctxt->objCache)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->nodesetObjs != NULL) &&
 	    (cache->nodesetObjs->number != 0))
@@ -2064,8 +2071,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
 {    
-    if ((ctxt != NULL) && (ctxt->objCache)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->stringObjs != NULL) &&
 	    (cache->stringObjs->number != 0))
@@ -2113,8 +2120,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
 {    
-    if ((ctxt != NULL) && (ctxt->objCache)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->stringObjs != NULL) &&
 	    (cache->stringObjs->number != 0))
@@ -2167,8 +2174,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
 {    
-    if ((ctxt != NULL) && (ctxt->objCache)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+    if ((ctxt != NULL) && (ctxt->cache)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->booleanObjs != NULL) &&
 	    (cache->booleanObjs->number != 0))
@@ -2215,8 +2222,8 @@
 static xmlXPathObjectPtr
 xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
 {
-     if ((ctxt != NULL) && (ctxt->objCache)) {
-	xmlXPathObjectCachePtr cache = (xmlXPathObjectCachePtr) ctxt->objCache;
+     if ((ctxt != NULL) && (ctxt->cache)) {
+	xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
 
 	if ((cache->numberObjs != NULL) &&
 	    (cache->numberObjs->number != 0))
@@ -5129,11 +5136,11 @@
 
     if (obj == NULL)
 	return;
-    if ((ctxt == NULL) || (ctxt->objCache == NULL)) {
+    if ((ctxt == NULL) || (ctxt->cache == NULL)) {
 	 xmlXPathFreeObject(obj);
     } else {       
-	xmlXPathObjectCachePtr cache =
-	    (xmlXPathObjectCachePtr) ctxt->objCache;
+	xmlXPathContextCachePtr cache =
+	    (xmlXPathContextCachePtr) ctxt->cache;
 
 	switch (obj->type) {
 	    case XPATH_NODESET:
@@ -5737,7 +5744,7 @@
     ret->proximityPosition = -1;
 
 #ifdef XP_DEFAULT_CACHE_ON
-    if (xmlXPathContextSetObjectCache(ret, 1, -1, 0) == -1) {
+    if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) {
 	xmlXPathFreeContext(ret);
 	return(NULL);
     }
@@ -5758,8 +5765,8 @@
 xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
     if (ctxt == NULL) return;
 
-    if (ctxt->objCache != NULL)
-	xmlXPathFreeObjectCache((xmlXPathObjectCachePtr) ctxt->objCache);
+    if (ctxt->cache != NULL)
+	xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
     xmlXPathRegisteredNsCleanup(ctxt);
     xmlXPathRegisteredFuncsCleanup(ctxt);
     xmlXPathRegisteredVariablesCleanup(ctxt);