* xmlXPathNewContext: * @doc: the XML document * * Create a new xmlXPathContext * * Returns the xmlXPathContext just allocated. The caller will need to free it. */
| 5094 | * Returns the xmlXPathContext just allocated. The caller will need to free it. |
| 5095 | */ |
| 5096 | xmlXPathContextPtr |
| 5097 | xmlXPathNewContext(xmlDocPtr doc) { |
| 5098 | xmlXPathContextPtr ret; |
| 5099 | |
| 5100 | ret = (xmlXPathContextPtr) xmlMalloc(sizeof(xmlXPathContext)); |
| 5101 | if (ret == NULL) |
| 5102 | return(NULL); |
| 5103 | memset(ret, 0 , sizeof(xmlXPathContext)); |
| 5104 | ret->doc = doc; |
| 5105 | ret->node = NULL; |
| 5106 | |
| 5107 | ret->varHash = NULL; |
| 5108 | |
| 5109 | ret->nb_types = 0; |
| 5110 | ret->max_types = 0; |
| 5111 | ret->types = NULL; |
| 5112 | |
| 5113 | ret->nb_axis = 0; |
| 5114 | ret->max_axis = 0; |
| 5115 | ret->axis = NULL; |
| 5116 | |
| 5117 | ret->nsHash = NULL; |
| 5118 | ret->user = NULL; |
| 5119 | |
| 5120 | ret->contextSize = -1; |
| 5121 | ret->proximityPosition = -1; |
| 5122 | |
| 5123 | #ifdef XP_DEFAULT_CACHE_ON |
| 5124 | if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) { |
| 5125 | xmlXPathFreeContext(ret); |
| 5126 | return(NULL); |
| 5127 | } |
| 5128 | #endif |
| 5129 | |
| 5130 | xmlXPathRegisterAllFunctions(ret); |
| 5131 | |
| 5132 | if (ret->lastError.code != XML_ERR_OK) { |
| 5133 | xmlXPathFreeContext(ret); |
| 5134 | return(NULL); |
| 5135 | } |
| 5136 | |
| 5137 | return(ret); |
| 5138 | } |
| 5139 | |
| 5140 | /** |
| 5141 | * xmlXPathFreeContext: |