您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmlMalloc函数代码示例

51自学网 2021-06-03 11:46:04
  C++
这篇教程C++ xmlMalloc函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmlMalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlMalloc函数的具体用法?C++ xmlMalloc怎么用?C++ xmlMalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmlMalloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xmlSchematronPushInclude

/** * xmlSchematronPushInclude: * @ctxt:  the schema parser context * @doc:  the included document * @cur:  the current include node * * Add an included document */static voidxmlSchematronPushInclude(xmlSchematronParserCtxtPtr ctxt,                        xmlDocPtr doc, xmlNodePtr cur){    if (ctxt->includes == NULL) {        ctxt->maxIncludes = 10;        ctxt->includes = (xmlNodePtr *)	    xmlMalloc(ctxt->maxIncludes * 2 * sizeof(xmlNodePtr));	if (ctxt->includes == NULL) {	    xmlSchematronPErrMemory(NULL, "allocating parser includes",				    NULL);	    return;	}        ctxt->nbIncludes = 0;    } else if (ctxt->nbIncludes + 2 >= ctxt->maxIncludes) {        xmlNodePtr *tmp;	tmp = (xmlNodePtr *)	    xmlRealloc(ctxt->includes, ctxt->maxIncludes * 4 *	               sizeof(xmlNodePtr));	if (tmp == NULL) {	    xmlSchematronPErrMemory(NULL, "allocating parser includes",				    NULL);	    return;	}        ctxt->includes = tmp;	ctxt->maxIncludes *= 2;    }    ctxt->includes[2 * ctxt->nbIncludes] = cur;    ctxt->includes[2 * ctxt->nbIncludes + 1] = (xmlNodePtr) doc;    ctxt->nbIncludes++;}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:40,


示例2: xmlCopyEntity

/** * xmlCopyEntity: * @ent:  An entity * * Build a copy of an entity *  * Returns the new xmlEntitiesPtr or NULL in case of error. */static xmlEntityPtrxmlCopyEntity(xmlEntityPtr ent) {    xmlEntityPtr cur;    cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));    if (cur == NULL) {	xmlGenericError(xmlGenericErrorContext,		"xmlCopyEntity: out of memory !/n");	return(NULL);    }    memset(cur, 0, sizeof(xmlEntity));    cur->type = XML_ENTITY_DECL;    cur->etype = ent->etype;    if (ent->name != NULL)	cur->name = xmlStrdup(ent->name);    if (ent->ExternalID != NULL)	cur->ExternalID = xmlStrdup(ent->ExternalID);    if (ent->SystemID != NULL)	cur->SystemID = xmlStrdup(ent->SystemID);    if (ent->content != NULL)	cur->content = xmlStrdup(ent->content);    if (ent->orig != NULL)	cur->orig = xmlStrdup(ent->orig);    if (ent->URI != NULL)	cur->URI = xmlStrdup(ent->URI);    return(cur);}
开发者ID:followheart,项目名称:try-catch-finally,代码行数:36,


示例3: xmlSchematronAddPattern

/** * xmlSchematronAddPattern: * @ctxt: the schema parsing context * @schema:  a schema structure * @node:  the node hosting the pattern * @id: the id or name of the pattern * * Add a pattern to a schematron * * Returns the new pointer or NULL in case of error */static xmlSchematronPatternPtrxmlSchematronAddPattern(xmlSchematronParserCtxtPtr ctxt,                     xmlSchematronPtr schema, xmlNodePtr node, xmlChar *name){    xmlSchematronPatternPtr ret;    if ((ctxt == NULL) || (schema == NULL) || (node == NULL) || (name == NULL))        return(NULL);    ret = (xmlSchematronPatternPtr) xmlMalloc(sizeof(xmlSchematronPattern));    if (ret == NULL) {        xmlSchematronPErrMemory(ctxt, "allocating schema pattern", node);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronPattern));    ret->name = name;    ret->next = NULL;    if (schema->patterns == NULL) {	schema->patterns = ret;    } else {        xmlSchematronPatternPtr prev = schema->patterns;	while (prev->next != NULL)	     prev = prev->next;        prev->next = ret;    }    return (ret);}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:39,


示例4: htmlNodeDumpFormat

/** * htmlNodeDumpFormat: * @buf:  the HTML buffer output * @doc:  the document * @cur:  the current node * @format:  should formatting spaces been added * * Dump an HTML node, recursive behaviour,children are printed too. * * Returns the number of byte written or -1 in case of error */static inthtmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,	           int format) {    unsigned int use;    int ret;    xmlOutputBufferPtr outbuf;    if (cur == NULL) {	return (-1);    }    if (buf == NULL) {	return (-1);    }    outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));    if (outbuf == NULL) {        htmlSaveErrMemory("allocating HTML output buffer");	return (-1);    }    memset(outbuf, 0, (size_t) sizeof(xmlOutputBuffer));    outbuf->buffer = buf;    outbuf->encoder = NULL;    outbuf->writecallback = NULL;    outbuf->closecallback = NULL;    outbuf->context = NULL;    outbuf->written = 0;    use = buf->use;    htmlNodeDumpFormatOutput(outbuf, doc, cur, NULL, format);    xmlFree(outbuf);    ret = buf->use - use;    return (ret);}
开发者ID:YadaryuZhyzn,项目名称:libxml2,代码行数:43,


示例5: xmlFindCharEncodingHandler

xmlChar *xml_convert_input(const char *in, const char *encoding) {	xmlChar *out;	int ret;	int size;	int out_size;	int temp;	xmlCharEncodingHandlerPtr handler;	handler = xmlFindCharEncodingHandler(encoding);	assert(handler != NULL);	size = (int)strlen(in) + 1;	out_size = size * 2 - 1;	out = (unsigned char *)xmlMalloc((size_t) out_size);	if (out != NULL) {		temp = size - 1;		ret = handler->input(out, &out_size, (const xmlChar *)in, &temp);		if ((ret < 0) || (temp - size + 1)) {			xmlFree(out);			out = 0;		} else {			out = (unsigned char *)xmlRealloc(out, out_size + 1);			out[out_size] = 0;  /*null terminating out */		}	}	return out;}
开发者ID:anantshri,项目名称:kraken,代码行数:25,


示例6: xmlSecEncCtxCreate

/** * xmlSecEncCtxCreate: * @keysMngr:           the pointer to keys manager. * * Creates <enc:EncryptedData/> element processing context. * The caller is responsible for destroying returned object by calling * #xmlSecEncCtxDestroy function. * * Returns: pointer to newly allocated context object or NULL if an error * occurs. */xmlSecEncCtxPtrxmlSecEncCtxCreate(xmlSecKeysMngrPtr keysMngr) {    xmlSecEncCtxPtr encCtx;    int ret;    encCtx = (xmlSecEncCtxPtr) xmlMalloc(sizeof(xmlSecEncCtx));    if(encCtx == NULL) {        xmlSecError(XMLSEC_ERRORS_HERE,                    NULL,                    NULL,                    XMLSEC_ERRORS_R_MALLOC_FAILED,                    "sizeof(xmlSecEncCtx)=%d",                    (int)sizeof(xmlSecEncCtx));        return(NULL);    }    ret = xmlSecEncCtxInitialize(encCtx, keysMngr);    if(ret < 0) {        xmlSecError(XMLSEC_ERRORS_HERE,                    NULL,                    "xmlSecEncCtxInitialize",                    XMLSEC_ERRORS_R_XMLSEC_FAILED,                    XMLSEC_ERRORS_NO_MESSAGE);        xmlSecEncCtxDestroy(encCtx);        return(NULL);    }    return(encCtx);}
开发者ID:KonstantinDavidov,项目名称:xmlsec,代码行数:39,


示例7: xz_error

static voidxz_error(xz_statep state, int err, const char *msg){    /* free previously allocated message and clear */    if (state->msg != NULL) {        if (state->err != LZMA_MEM_ERROR)            xmlFree(state->msg);        state->msg = NULL;    }    /* set error code, and if no message, then done */    state->err = err;    if (msg == NULL)        return;    /* for an out of memory error, save as static string */    if (err == LZMA_MEM_ERROR) {        state->msg = (char *) msg;        return;    }    /* construct error message with path */    if ((state->msg =         xmlMalloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {        state->err = LZMA_MEM_ERROR;        state->msg = (char *) "out of memory";        return;    }    strcpy(state->msg, state->path);    strcat(state->msg, ": ");    strcat(state->msg, msg);    return;}
开发者ID:AfzalMasood11,项目名称:RailsIntranetApp,代码行数:33,


示例8: xmlBufCreate

/** * xmlBufCreate: * * routine to create an XML buffer. * returns the new structure. */xmlBufPtrxmlBufCreate(void) {    xmlBufPtr ret;    ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));    if (ret == NULL) {	xmlBufMemoryError(NULL, "creating buffer");        return(NULL);    }    ret->compat_use = 0;    ret->use = 0;    ret->error = 0;    ret->buffer = NULL;    ret->size = xmlDefaultBufferSize;    ret->compat_size = xmlDefaultBufferSize;    ret->alloc = xmlBufferAllocScheme;    ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));    if (ret->content == NULL) {	xmlBufMemoryError(ret, "creating buffer");	xmlFree(ret);        return(NULL);    }    ret->content[0] = 0;    ret->contentIO = NULL;    return(ret);}
开发者ID:GerHobbelt,项目名称:libxml2,代码行数:32,


示例9: xmlSetGlobalState

/* Problem: *   - xmlSetGlobalState may need to either ``copy'' memory *     from one place to another or ``change a pointer''. * *   - changing a pointer requires: *       an ** where to save the old pointer *       a new * to set instead of the old one *   - copying memory requires  *       a memory area where to save the old state *       a new memory area to copy over the current state *    *   In either cases, the SetGlobalState must be transparent *   to the user  * */int xmlSetGlobalState(xmlGlobalStatePtr new_state, xmlGlobalStatePtr * old_state) {  xmlGlobalStatePtr global;  int retval=1;      /* Get a pointer to the current      * memory area */  global=xmlGetGlobalState();    /* If the user wants to     * save the current state somewhere */  if(old_state) {    *old_state=(xmlGlobalStatePtr)xmlMalloc(sizeof(xmlGlobalState));    if(*old_state)      memcpy(*old_state, global, sizeof(xmlGlobalState));    else      retval=0;  }    /* If the user provides a new_state state      * and the copy was succesfull */  if(new_state && (!old_state || *old_state)) {    memcpy(global, new_state, sizeof(xmlGlobalState));    xmlFree(new_state);  }    /* Return status */  return retval;}
开发者ID:ccontavalli,项目名称:mod-xslt,代码行数:42,


示例10: xmlSchematronNewMemParserCtxt

/** * xmlSchematronNewMemParserCtxt: * @buffer:  a pointer to a char array containing the schemas * @size:  the size of the array * * Create an XML Schematrons parse context for that memory buffer expected * to contain an XML Schematrons file. * * Returns the parser context or NULL in case of error */xmlSchematronParserCtxtPtrxmlSchematronNewMemParserCtxt(const char *buffer, int size){    xmlSchematronParserCtxtPtr ret;    if ((buffer == NULL) || (size <= 0))        return (NULL);    ret =        (xmlSchematronParserCtxtPtr)        xmlMalloc(sizeof(xmlSchematronParserCtxt));    if (ret == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser context",                                NULL);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronParserCtxt));    ret->buffer = buffer;    ret->size = size;    ret->dict = xmlDictCreate();    ret->xctxt = xmlXPathNewContext(NULL);    if (ret->xctxt == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context",                                NULL);	xmlSchematronFreeParserCtxt(ret);        return (NULL);    }    return (ret);}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:39,


示例11: xmlSchematronNewDocParserCtxt

/** * xmlSchematronNewDocParserCtxt: * @doc:  a preparsed document tree * * Create an XML Schematrons parse context for that document. * NB. The document may be modified during the parsing process. * * Returns the parser context or NULL in case of error */xmlSchematronParserCtxtPtrxmlSchematronNewDocParserCtxt(xmlDocPtr doc){    xmlSchematronParserCtxtPtr ret;    if (doc == NULL)        return (NULL);    ret =        (xmlSchematronParserCtxtPtr)        xmlMalloc(sizeof(xmlSchematronParserCtxt));    if (ret == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser context",                                NULL);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronParserCtxt));    ret->doc = doc;    ret->dict = xmlDictCreate();    /* The application has responsibility for the document */    ret->preserve = 1;    ret->xctxt = xmlXPathNewContext(doc);    if (ret->xctxt == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context",                                NULL);	xmlSchematronFreeParserCtxt(ret);        return (NULL);    }    return (ret);}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:40,


示例12: exsltFuncInit

/** * exsltFuncInit: * @ctxt: an XSLT transformation context * @URI: the namespace URI for the extension * * Initializes the EXSLT - Functions module. * Called at transformation-time; merges all * functions declared in the import tree taking * import precedence into account, i.e. overriding * functions with lower import precedence. * * Returns the data for this transformation */static exsltFuncData *exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) {    exsltFuncData *ret;    xsltStylesheetPtr tmp;    exsltFuncImportRegData ch;    xmlHashTablePtr hash;    ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData));    if (ret == NULL) {	xsltGenericError(xsltGenericErrorContext,			 "exsltFuncInit: not enough memory/n");	return(NULL);    }    memset(ret, 0, sizeof(exsltFuncData));    ret->result = NULL;    ret->error = 0;    ch.hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI);    ret->funcs = ch.hash;    xmlHashScanFull(ch.hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt);    tmp = ctxt->style;    ch.ctxt = ctxt;    while ((tmp=xsltNextImport(tmp))!=NULL) {	hash = xsltGetExtInfo(tmp, URI);	if (hash != NULL) {	    xmlHashScanFull(hash,		    (xmlHashScannerFull) exsltFuncRegisterImportFunc, &ch);	}    }    return(ret);}
开发者ID:winlibs,项目名称:libxslt,代码行数:46,


示例13: xmlSchematronNewParserCtxt

/** * xmlSchematronNewParserCtxt: * @URL:  the location of the schema * * Create an XML Schematrons parse context for that file/resource expected * to contain an XML Schematrons file. * * Returns the parser context or NULL in case of error */xmlSchematronParserCtxtPtrxmlSchematronNewParserCtxt(const char *URL){    xmlSchematronParserCtxtPtr ret;    if (URL == NULL)        return (NULL);    ret =        (xmlSchematronParserCtxtPtr)        xmlMalloc(sizeof(xmlSchematronParserCtxt));    if (ret == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser context",                                NULL);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronParserCtxt));    ret->type = XML_STRON_CTXT_PARSER;    ret->dict = xmlDictCreate();    ret->URL = xmlDictLookup(ret->dict, (const xmlChar *) URL, -1);    ret->includes = NULL;    ret->xctxt = xmlXPathNewContext(NULL);    if (ret->xctxt == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context",                                NULL);	xmlSchematronFreeParserCtxt(ret);        return (NULL);    }    ret->xctxt->flags = XML_XPATH_CHECKNS;    return (ret);}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:40,


示例14: rxml_sax_parser_parse

/* * call-seq: *    parser.parse -> (true|false) * * Parse the input XML, generating callbacks to the object * registered via the +callbacks+ attributesibute. */static VALUE rxml_sax_parser_parse(VALUE self){  int status;  VALUE context = rb_ivar_get(self, CONTEXT_ATTR);  xmlParserCtxtPtr ctxt;  Data_Get_Struct(context, xmlParserCtxt, ctxt);  ctxt->sax2 = 1;	ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);  if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)    xmlFree(ctxt->sax);      ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(rxml_sax_handler));  if (ctxt->sax == NULL)    rb_fatal("Not enough memory.");  memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));      status = xmlParseDocument(ctxt);  /* Now check the parsing result*/  if (status == -1 || !ctxt->wellFormed)  {    if (ctxt->myDoc)      xmlFreeDoc(ctxt->myDoc);    rxml_raise(&ctxt->lastError);  }  return Qtrue;}
开发者ID:Blackmist,项目名称:libxml-ruby,代码行数:37,


示例15: xmlSchematronNewValidCtxt

/** * xmlSchematronNewValidCtxt: * @schema:  a precompiled XML Schematrons * @options: a set of xmlSchematronValidOptions * * Create an XML Schematrons validation context based on the given schema. * * Returns the validation context or NULL in case of error */xmlSchematronValidCtxtPtrxmlSchematronNewValidCtxt(xmlSchematronPtr schema, int options){    int i;    xmlSchematronValidCtxtPtr ret;    ret = (xmlSchematronValidCtxtPtr) xmlMalloc(sizeof(xmlSchematronValidCtxt));    if (ret == NULL) {        xmlSchematronVErrMemory(NULL, "allocating validation context",                                NULL);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronValidCtxt));    ret->type = XML_STRON_CTXT_VALIDATOR;    ret->schema = schema;    ret->xctxt = xmlXPathNewContext(NULL);    ret->flags = options;    if (ret->xctxt == NULL) {        xmlSchematronPErrMemory(NULL, "allocating schema parser XPath context",                                NULL);	xmlSchematronFreeValidCtxt(ret);        return (NULL);    }    for (i = 0;i < schema->nbNamespaces;i++) {        if ((schema->namespaces[2 * i] == NULL) ||            (schema->namespaces[2 * i + 1] == NULL))	    break;	xmlXPathRegisterNs(ret->xctxt, schema->namespaces[2 * i + 1],	                   schema->namespaces[2 * i]);    }    return (ret);}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:41,


示例16: xmlNewPatParserContext

/** * xmlNewPatParserContext: * @pattern:  the pattern context * @dict:  the inherited dictionnary or NULL * @namespaces: the prefix definitions, array of [URI, prefix] or NULL * * Create a new XML pattern parser context * * Returns the newly allocated xmlPatParserContextPtr or NULL in case of error */static xmlPatParserContextPtrxmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,                       const xmlChar **namespaces) {    xmlPatParserContextPtr cur;    if (pattern == NULL)        return(NULL);    cur = (xmlPatParserContextPtr) xmlMalloc(sizeof(xmlPatParserContext));    if (cur == NULL) {	ERROR(NULL, NULL, NULL,		"xmlNewPatParserContext : malloc failed/n");	return(NULL);    }    memset(cur, 0, sizeof(xmlPatParserContext));    cur->dict = dict;    cur->cur = pattern;    cur->base = pattern;    if (namespaces != NULL) {        int i;	for (i = 0;namespaces[2 * i] != NULL;i++);        cur->nb_namespaces = i;    } else {        cur->nb_namespaces = 0;    }    cur->namespaces = namespaces;    return(cur);}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:38,


示例17: xmlModuleOpen

/** * xmlModuleOpen: * @name: the module name * @options: a set of xmlModuleOption * * Opens a module/shared library given its name or path * TODO: options are not yet implemented. * * Returns a handle for the module or NULL in case of error */xmlModulePtrxmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED){    xmlModulePtr module;    module = (xmlModulePtr) xmlMalloc(sizeof(xmlModule));    if (module == NULL) {        xmlModuleErrMemory(NULL, "creating module");        return (NULL);    }    memset(module, 0, sizeof(xmlModule));    module->handle = xmlModulePlatformOpen(name);    if (module->handle == NULL) {        xmlFree(module);        __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,                        XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,                        name, NULL, 0, 0, "failed to open %s/n", name);        return(NULL);    }    module->name = xmlStrdup((const xmlChar *) name);    return (module);}
开发者ID:Ashod,项目名称:WinCairoRequirements,代码行数:36,


示例18: find_node_set

/** * @arg xpath XPath expression to evaluate * @doc document over which to evaluate * @arg pctxt can be NULL * @return list of matching nodes. The caller will have to free it using xmlXPathFreeNodeSet(). */xmlNodeSetPtr find_node_set(const char *xpath, const xmlDocPtr doc, xmlXPathParserContextPtr *pctxt){  xmlXPathContextPtr ctxt = xmlXPathNewContext(doc);  if(!ctxt)  {    g_printerr(G_STRLOC ": Failed to allocate XPathContext!/n");    return NULL;  }  if(xmlXPathRegisterNs(ctxt, (xmlChar *) FREEDICT_EDITOR_NAMESPACE_PREFIX, (xmlChar *) FREEDICT_EDITOR_NAMESPACE))  {    g_printerr("Warning: Unable to register XSLT-Namespace prefix /"%s/""	" for URI /"%s/"/n", FREEDICT_EDITOR_NAMESPACE_PREFIX, FREEDICT_EDITOR_NAMESPACE);  }  if(xmlXPathRegisterFuncNS(ctxt, (xmlChar *) "unbalanced-braces",	(xmlChar *) FREEDICT_EDITOR_NAMESPACE, freedict_xpath_extension_unbalanced_braces))    g_printerr("Warning: Unable to register XPath extension function "	"/"unbalanced-braces/" for URI /"%s/"/n", FREEDICT_EDITOR_NAMESPACE);  xmlXPathParserContextPtr pctxt2;  if(!pctxt) pctxt = &pctxt2;  xmlXPathObjectPtr xpobj = my_xmlXPathEvalExpression((xmlChar *) xpath, ctxt, pctxt);  if(!xpobj)  {    g_printerr(G_STRLOC ": No XPathObject!/n");    xmlXPathFreeContext(ctxt);    return NULL;  }  if(!(xpobj->nodesetval))  {    g_printerr(G_STRLOC ": No nodeset!/n");    xmlXPathFreeObject(xpobj);    xmlXPathFreeContext(ctxt);    return NULL;  }  if(!(xpobj->nodesetval->nodeNr))  {    //g_printerr("0 nodes!/n");    xmlXPathFreeObject(xpobj);    xmlXPathFreeContext(ctxt);    return NULL;  }  xmlXPathFreeContext(ctxt);  xmlNodeSetPtr nodes = xmlMalloc(sizeof(xmlNodeSet));  // XXX copying is slow...  memcpy(nodes, xpobj->nodesetval, sizeof(xmlNodeSet));  // I don't understand the naming of this function.  According to the  // documentation, it frees xpobj, but not its nodelist, if it  // contained one. So it should be called xmlXPathFreeObjectButNotNodeSetList().  xmlXPathFreeNodeSetList(xpobj);  return nodes;}
开发者ID:dhyannataraj,项目名称:fd-dictionaries,代码行数:65,


示例19: xmlNewGlobalState

xmlGlobalStatePtr xmlNewGlobalState(void) {  xmlGlobalStatePtr retval;  retval=(xmlGlobalStatePtr)(xmlMalloc(sizeof(xmlGlobalState)));  xmlInitializeGlobalState(retval);  return retval;}
开发者ID:ccontavalli,项目名称:mod-xslt,代码行数:8,


示例20: xmlCreateEntity

/* * xmlCreateEntity: * * internal routine doing the entity node strutures allocations */static xmlEntityPtrxmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,                const xmlChar *ExternalID, const xmlChar *SystemID,                const xmlChar *content){  xmlEntityPtr ret;  ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));  if (ret == NULL)  {    xmlEntitiesErrMemory("xmlCreateEntity: malloc failed");    return(NULL);  }  memset(ret, 0, sizeof(xmlEntity));  ret->type = XML_ENTITY_DECL;  ret->checked = 0;  /*   * fill the structure.   */  ret->etype = (xmlEntityType) type;  if (dict == NULL)  {    ret->name = xmlStrdup(name);    if (ExternalID != NULL)      ret->ExternalID = xmlStrdup(ExternalID);    if (SystemID != NULL)      ret->SystemID = xmlStrdup(SystemID);  }  else  {    ret->name = xmlDictLookup(dict, name, -1);    if (ExternalID != NULL)      ret->ExternalID = xmlDictLookup(dict, ExternalID, -1);    if (SystemID != NULL)      ret->SystemID = xmlDictLookup(dict, SystemID, -1);  }  if (content != NULL)  {    ret->length = xmlStrlen(content);    if ((dict != NULL) && (ret->length < 5))      ret->content = (xmlChar *)                     xmlDictLookup(dict, content, ret->length);    else      ret->content = xmlStrndup(content, ret->length);  }  else  {    ret->length = 0;    ret->content = NULL;  }  ret->URI = NULL; /* to be computed by the layer knowing       the defining entity */  ret->orig = NULL;  ret->owner = 0;  return(ret);}
开发者ID:vgurev,项目名称:freesurfer,代码行数:63,


示例21: xmlHashCreate

PyObject *xmlsec_PtrListIdCreate(PyObject *self, PyObject *args) {  PyObject *duplicateItem_obj, *destroyItem_obj;  PyObject *debugDumpItem_obj, *debugXmlDumpItem_obj;  const xmlChar *name;  struct _xmlSecPtrListKlass *listId;  if (CheckArgs(args, "Scccc:ptrListIdCreate")) {    if(!PyArg_ParseTuple(args, (char *) "sOOOO:ptrListIdCreate", &name,			 &duplicateItem_obj, &destroyItem_obj,			 &debugDumpItem_obj, &debugXmlDumpItem_obj))      return NULL;  }  else return NULL;    if (PtrDuplicateItemMethods == NULL && duplicateItem_obj != Py_None)    PtrDuplicateItemMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (PtrDestroyItemMethods == NULL && destroyItem_obj != Py_None)    PtrDestroyItemMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (PtrDebugDumpItemMethods == NULL && debugDumpItem_obj != Py_None)    PtrDebugDumpItemMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (PtrDebugXmlDumpItemMethods == NULL && debugXmlDumpItem_obj != Py_None)    PtrDebugXmlDumpItemMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (duplicateItem_obj != Py_None)    xmlHashAddEntry(PtrDuplicateItemMethods, name, duplicateItem_obj);  if (destroyItem_obj != Py_None)    xmlHashAddEntry(PtrDestroyItemMethods,   name, destroyItem_obj);  if (debugDumpItem_obj != Py_None)    xmlHashAddEntry(PtrDebugDumpItemMethods, name, debugDumpItem_obj);  if (debugXmlDumpItem_obj != Py_None)    xmlHashAddEntry(PtrDebugXmlDumpItemMethods, name, debugXmlDumpItem_obj);  listId = xmlMalloc(sizeof(xmlSecPtrListKlass));  listId->name = name;  if (duplicateItem_obj != Py_None)    listId->duplicateItem = xmlsec_PtrDuplicateItemMethod;  else    listId->duplicateItem = NULL;  if (destroyItem_obj != Py_None)    listId->destroyItem = xmlsec_PtrDestroyItemMethod;  else    listId->destroyItem = NULL;  if (debugDumpItem_obj != Py_None)    listId->debugDumpItem = xmlsec_PtrDebugDumpItemMethod;  else    listId->debugDumpItem = NULL;  if (debugXmlDumpItem_obj != Py_None)    listId->debugXmlDumpItem = xmlsec_PtrDebugXmlDumpItemMethod;  else    listId->debugXmlDumpItem = NULL;  Py_XINCREF(duplicateItem_obj);  Py_XINCREF(destroyItem_obj);  Py_XINCREF(debugDumpItem_obj);  Py_XINCREF(debugXmlDumpItem_obj);  return (wrap_xmlSecPtrListId(listId));}
开发者ID:DeltaOS,项目名称:pyxmlsec,代码行数:58,


示例22: xmlHashCreate

PyObject *keysmngr_KeyStoreIdCreate(PyObject *self, PyObject *args) {  PyObject *initialize_obj, *finalize_obj, *findKey_obj;  xmlSecSize klassSize;  xmlSecSize objSize;  const xmlChar *name;      struct _xmlSecKeyStoreKlass *storeId;  if (CheckArgs(args, "IISccc:keyStoreIdCreate")) {    if(!PyArg_ParseTuple(args, (char *) "iisOOO:keyStoreIdCreate", &klassSize,			 &objSize, &name, &initialize_obj, &finalize_obj,			 &findKey_obj))      return NULL;  }  else return NULL;    if (KeyStoreInitializeMethods == NULL && initialize_obj != Py_None)    KeyStoreInitializeMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (KeyStoreFinalizeMethods == NULL && finalize_obj != Py_None)    KeyStoreFinalizeMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (KeyStoreFindKeyMethods == NULL && findKey_obj != Py_None)    KeyStoreFindKeyMethods = xmlHashCreate(HASH_TABLE_SIZE);  if (initialize_obj != Py_None)    xmlHashAddEntry(KeyStoreInitializeMethods, name, initialize_obj);  if (finalize_obj != Py_None)    xmlHashAddEntry(KeyStoreFinalizeMethods,   name, finalize_obj);  if (findKey_obj != Py_None)    xmlHashAddEntry(KeyStoreFindKeyMethods,    name, findKey_obj);  storeId = xmlMalloc(sizeof(xmlSecKeyStoreKlass));  /* FIXME    storeId->klassSize = klassSize;    storeId->objSize = objSize;  */  storeId->klassSize = sizeof(xmlSecKeyStoreKlass);  storeId->objSize = sizeof(xmlSecKeyStore);  storeId->name = (xmlChar *)strdup((const char *)name);  if (initialize_obj != Py_None)    storeId->initialize = (xmlSecKeyStoreInitializeMethod)xmlsec_KeyStoreInitializeMethod;  else    storeId->initialize = NULL;  if (finalize_obj != Py_None)    storeId->finalize = (xmlSecKeyStoreFinalizeMethod)xmlsec_KeyStoreFinalizeMethod;  else    storeId->finalize = NULL;  if (findKey_obj != Py_None)    storeId->findKey = (xmlSecKeyStoreFindKeyMethod)xmlsec_KeyStoreFindKeyMethod;  else    storeId->findKey = NULL;  Py_XINCREF(initialize_obj);  Py_XINCREF(finalize_obj);  Py_XINCREF(findKey_obj);  return (wrap_xmlSecKeyStoreId(storeId));}
开发者ID:dnet,项目名称:pyxmlsec,代码行数:58,


示例23: xmlDictAddQString

/* * xmlDictAddQString: * @dict: the dictionary * @prefix: the prefix of the userdata * @plen: the prefix length * @name: the name of the userdata * @len: the length of the name * * Add the QName to the array[s] * * Returns the pointer of the local string, or NULL in case of error. */static const xmlChar *xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen,                 const xmlChar *name, unsigned int namelen){    xmlDictStringsPtr pool;    const xmlChar *ret;    size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */    size_t limit = 0;    if (prefix == NULL) return(xmlDictAddString(dict, name, namelen));#ifdef DICT_DEBUG_PATTERNS    fprintf(stderr, "=");#endif    pool = dict->strings;    while (pool != NULL) {	if (pool->end - pool->free > namelen + plen + 1)	    goto found_pool;	if (pool->size > size) size = pool->size;        limit += pool->size;	pool = pool->next;    }    /*     * Not found, need to allocate     */    if (pool == NULL) {        if ((dict->limit > 0) && (limit > dict->limit)) {            return(NULL);        }        if (size == 0) size = 1000;	else size *= 4; /* exponential growth */        if (size < 4 * (namelen + plen + 1))	    size = 4 * (namelen + plen + 1); /* just in case ! */	pool = (xmlDictStringsPtr) xmlMalloc(sizeof(xmlDictStrings) + size);	if (pool == NULL)	    return(NULL);	pool->size = size;	pool->nbStrings = 0;	pool->free = &pool->array[0];	pool->end = &pool->array[size];	pool->next = dict->strings;	dict->strings = pool;#ifdef DICT_DEBUG_PATTERNS        fprintf(stderr, "+");#endif    }found_pool:    ret = pool->free;    memcpy(pool->free, prefix, plen);    pool->free += plen;    *(pool->free++) = ':';    memcpy(pool->free, name, namelen);    pool->free += namelen;    *(pool->free++) = 0;    pool->nbStrings++;    return(ret);}
开发者ID:CMXWL,项目名称:libxml2,代码行数:70,


示例24: ermXmlGetChildNodeSet

xmlNodeSetPtr ermXmlGetChildNodeSet(xmlNodePtr parent, const char* childName){    int  i;    xmlNodeSetPtr nodeSet = NULL;  // return value    xmlNodePtr    cur     = NULL;    //TRACE("entry: parent [%p] [%s]", parent, parent ? parent->name : NULL);    //TRACE("entry: node [%s]", childName);    // allocate space for nodeset    nodeSet = xmlMalloc( sizeof(xmlNodeSet) );    if (nodeSet == NULL) { return NULL; }    nodeSet->nodeNr  = 0;    nodeSet->nodeMax = 10;    nodeSet->nodeTab = xmlMalloc(10 * sizeof(xmlNode));    if (nodeSet->nodeTab == NULL) { return NULL; }        if (parent && childName && childName[0] != '/0')    {        cur = parent->children;        while (cur != NULL)        {            if ( xmlStrcmp(cur->name, (const xmlChar*)childName) == 0 )            {                //TRACE("Found child node %s", childName);                // extend space for nodeset                if (nodeSet->nodeNr >= nodeSet->nodeMax)                {                    i = 2 * nodeSet->nodeMax;                    nodeSet->nodeMax = i;                    nodeSet->nodeTab = xmlRealloc(nodeSet->nodeTab, i * sizeof(xmlNode));                    if (nodeSet->nodeTab == NULL) { return NULL; }                }                // add node to nodeset                nodeSet->nodeTab[ nodeSet->nodeNr ] = cur;                nodeSet->nodeNr++;            }            cur = cur->next;        }    }    return nodeSet;}
开发者ID:vastin,项目名称:iliad-hacking,代码行数:45,


示例25: xmlFindCharEncodingHandler

/** * ConvertInput: * @in: string in a given encoding * @encoding: the encoding used * * Converts @in into UTF-8 for processing with libxml2 APIs * * Returns the converted UTF-8 string, or NULL in case of error. */xmlChar* cpXmlCmdOutput::ConvertInput( const xmlChar* in, const xmlChar* encoding ){   xmlChar *out;   int ret;   int size;   int out_size;   int temp;   xmlCharEncodingHandlerPtr handler;   if ( in == 0 )      return 0;   handler = xmlFindCharEncodingHandler( (const char *)encoding );   if ( !handler )   {      printf( "ConvertInput: no encoding handler found for '%s'/n", encoding != 0 ? (const char *)encoding : "" );      return 0;   }   size = (int) strlen( (const char*) in ) + 1;   out_size = size * 2 - 1;   out = (xmlChar *) xmlMalloc( (size_t) out_size );   if ( out != 0 )   {      temp = size - 1;      ret = handler->input( out, &out_size, in, &temp );      if ( ( ret < 0 ) || ( temp - size + 1 ) )      {         if ( ret < 0 )         {            printf( "ConvertInput: conversion wasn't successful./n" );         }         else         {            printf               ( "ConvertInput: conversion wasn't successful. converted: %i octets./n",               temp );         }         xmlFree( out );         out = 0;      }      else      {         out = (xmlChar *) xmlRealloc( out, out_size + 1 );         out[out_size] = 0; //null termination      }   }   else   {      printf( "ConvertInput: no mem/n" );   }   return out;}
开发者ID:jsprenkle,项目名称:cpXmlCmd,代码行数:66,


示例26: xmlHashUpdateEntry3

/** * xmlHashUpdateEntry3: * @table: the hash table * @name: the name of the userdata * @name2: a second name of the userdata * @name3: a third name of the userdata * @userdata: a pointer to the userdata * @f: the deallocator function for replaced item (if any) * * Add the @userdata to the hash @table. This can later be retrieved * by using the tuple (@name, @name2, @name3). Existing entry for this tuple * will be removed and freed with @f if found. * * Returns 0 the addition succeeded and -1 in case of error. */intxmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name,	           const xmlChar *name2, const xmlChar *name3,		   void *userdata, xmlHashDeallocator f) {    unsigned long key;    xmlHashEntryPtr entry;    xmlHashEntryPtr insert;    if ((table == NULL) || name == NULL)	return(-1);    /*     * Check for duplicate and insertion location.     */    key = xmlHashComputeKey(table, name, name2, name3);    if (table->table[key] == NULL) {	insert = NULL;    } else {	for (insert = table->table[key]; insert->next != NULL;	     insert = insert->next) {	    if ((xmlStrEqual(insert->name, name)) &&		(xmlStrEqual(insert->name2, name2)) &&		(xmlStrEqual(insert->name3, name3))) {		if (f)		    f(insert->payload, insert->name);		insert->payload = userdata;		return(0);	    }	}	if ((xmlStrEqual(insert->name, name)) &&	    (xmlStrEqual(insert->name2, name2)) &&	    (xmlStrEqual(insert->name3, name3))) {	    if (f)		f(insert->payload, insert->name);	    insert->payload = userdata;	    return(0);	}    }    entry = xmlMalloc(sizeof(xmlHashEntry));    if (entry == NULL)	return(-1);    entry->name = xmlStrdup(name);    entry->name2 = xmlStrdup(name2);    entry->name3 = xmlStrdup(name3);    entry->payload = userdata;    entry->next = NULL;    table->nbElems++;    if (insert == NULL) {	table->table[key] = entry;    } else {	insert->next = entry;    }    return(0);}
开发者ID:gitpan,项目名称:AxKit-Needs,代码行数:72,


示例27: xmlSchematronAddRule

/** * xmlSchematronAddRule: * @ctxt: the schema parsing context * @schema:  a schema structure * @node:  the node hosting the rule * @context: the associated context string * @report: the associated report string * * Add a rule to a schematron * * Returns the new pointer or NULL in case of error */static xmlSchematronRulePtrxmlSchematronAddRule(xmlSchematronParserCtxtPtr ctxt, xmlSchematronPtr schema,                     xmlSchematronPatternPtr pat, xmlNodePtr node,		     xmlChar *context, xmlChar *report){    xmlSchematronRulePtr ret;    xmlPatternPtr pattern;    if ((ctxt == NULL) || (schema == NULL) || (node == NULL) ||        (context == NULL))        return(NULL);    /*     * Try first to compile the pattern     */    pattern = xmlPatterncompile(context, ctxt->dict, XML_PATTERN_XPATH,                                ctxt->namespaces);    if (pattern == NULL) {	xmlSchematronPErr(ctxt, node,	    XML_SCHEMAP_NOROOT,	    "Failed to compile context expression %s",	    context, NULL);    }    ret = (xmlSchematronRulePtr) xmlMalloc(sizeof(xmlSchematronRule));    if (ret == NULL) {        xmlSchematronPErrMemory(ctxt, "allocating schema rule", node);        return (NULL);    }    memset(ret, 0, sizeof(xmlSchematronRule));    ret->node = node;    ret->context = context;    ret->pattern = pattern;    ret->report = report;    ret->next = NULL;    if (schema->rules == NULL) {	schema->rules = ret;    } else {        xmlSchematronRulePtr prev = schema->rules;	while (prev->next != NULL)	     prev = prev->next;        prev->next = ret;    }    ret->patnext = NULL;    if (pat->rules == NULL) {	pat->rules = ret;    } else {        xmlSchematronRulePtr prev = pat->rules;	while (prev->patnext != NULL)	     prev = prev->patnext;        prev->patnext = ret;    }    return (ret);}
开发者ID:AllenChanAncA,项目名称:WiEngine,代码行数:68,


示例28: _build_entity

static void_build_entity(const xmlChar *name, int len, xmlChar **entity, int *entity_len) {	*entity_len = len + 2;	*entity = xmlMalloc(*entity_len + 1);	(*entity)[0] = '&';	memcpy(*entity+1, name, len);	(*entity)[len+1] = ';';	(*entity)[*entity_len] = '/0';}
开发者ID:practicalweb,项目名称:php-src,代码行数:10,


示例29: xmlHashCreate

/** * xmlHashCreate: * @size: the size of the hash table * * Create a new xmlHashTablePtr. * * Returns the newly created object, or NULL if an error occured. */xmlHashTablePtrxmlHashCreate(int size) {    xmlHashTablePtr table;      if (size <= 0)        size = 256;      table = xmlMalloc(sizeof(xmlHashTable));    if (table) {        table->size = size;	table->nbElems = 0;        table->table = xmlMalloc(size * sizeof(xmlHashEntryPtr));        if (table->table) {  	    memset(table->table, 0, size * sizeof(xmlHashEntryPtr));  	    return(table);        }        xmlFree(table);    }    return(NULL);}
开发者ID:gitpan,项目名称:AxKit-Needs,代码行数:28,


示例30: xmlHashAddEntry3

/** * xmlHashAddEntry3: * @table: the hash table * @name: the name of the userdata * @name2: a second name of the userdata * @name3: a third name of the userdata * @userdata: a pointer to the userdata * * Add the @userdata to the hash @table. This can later be retrieved * by using the tuple (@name, @name2, @name3). Duplicate entries generate * errors. * * Returns 0 the addition succeeded and -1 in case of error. */intxmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,	         const xmlChar *name2, const xmlChar *name3,		 void *userdata) {    unsigned long key, len = 0;    xmlHashEntryPtr entry;    xmlHashEntryPtr insert;    if ((table == NULL) || name == NULL)	return(-1);    /*     * Check for duplicate and insertion location.     */    key = xmlHashComputeKey(table, name, name2, name3);    if (table->table[key] == NULL) {	insert = NULL;    } else {	for (insert = table->table[key]; insert->next != NULL;	     insert = insert->next) {	    if ((xmlStrEqual(insert->name, name)) &&		(xmlStrEqual(insert->name2, name2)) &&		(xmlStrEqual(insert->name3, name3)))		return(-1);	    len++;	}	if ((xmlStrEqual(insert->name, name)) &&	    (xmlStrEqual(insert->name2, name2)) &&	    (xmlStrEqual(insert->name3, name3)))	    return(-1);    }    entry = xmlMalloc(sizeof(xmlHashEntry));    if (entry == NULL)	return(-1);    entry->name = xmlStrdup(name);    entry->name2 = xmlStrdup(name2);    entry->name3 = xmlStrdup(name3);    entry->payload = userdata;    entry->next = NULL;    if (insert == NULL) {	table->table[key] = entry;    } else {	insert->next = entry;    }    table->nbElems++;    if (len > MAX_HASH_LEN)	xmlHashGrow(table, MAX_HASH_LEN * table->size);    return(0);}
开发者ID:gitpan,项目名称:AxKit-Needs,代码行数:68,



注:本文中的xmlMalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xmlMutexLock函数代码示例
C++ xmlKeepBlanksDefault函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。