MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSplitQName

Function xmlSplitQName

ThirdParty/libxml2/vtklibxml2/parser.c:2988–3148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2986 */
2987
2988xmlChar *
2989xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
2990 xmlChar buf[XML_MAX_NAMELEN + 5];
2991 xmlChar *buffer = NULL;
2992 int len = 0;
2993 int max = XML_MAX_NAMELEN;
2994 xmlChar *ret = NULL;
2995 xmlChar *prefix;
2996 const xmlChar *cur = name;
2997 int c;
2998
2999 if (prefixOut == NULL) return(NULL);
3000 *prefixOut = NULL;
3001
3002 if (cur == NULL) return(NULL);
3003
3004 /* nasty but well=formed */
3005 if (cur[0] == ':')
3006 return(xmlStrdup(name));
3007
3008 c = *cur++;
3009 while ((c != 0) && (c != ':') && (len < max)) { /* tested bigname.xml */
3010 buf[len++] = c;
3011 c = *cur++;
3012 }
3013 if (len >= max) {
3014 /*
3015 * Okay someone managed to make a huge name, so he's ready to pay
3016 * for the processing speed.
3017 */
3018 max = len * 2;
3019
3020 buffer = (xmlChar *) xmlMallocAtomic(max);
3021 if (buffer == NULL) {
3022 xmlErrMemory(ctxt);
3023 return(NULL);
3024 }
3025 memcpy(buffer, buf, len);
3026 while ((c != 0) && (c != ':')) { /* tested bigname.xml */
3027 if (len + 10 > max) {
3028 xmlChar *tmp;
3029
3030 max *= 2;
3031 tmp = (xmlChar *) xmlRealloc(buffer, max);
3032 if (tmp == NULL) {
3033 xmlFree(buffer);
3034 xmlErrMemory(ctxt);
3035 return(NULL);
3036 }
3037 buffer = tmp;
3038 }
3039 buffer[len++] = c;
3040 c = *cur++;
3041 }
3042 buffer[len] = 0;
3043 }
3044
3045 if ((c == ':') && (*cur == 0)) {

Callers 3

xmlSAX2AttributeDeclFunction · 0.85
SAX2.cFile · 0.85
xmlSAX2StartElementFunction · 0.85

Calls 3

xmlStrdupFunction · 0.85
xmlErrMemoryFunction · 0.85
xmlStrndupFunction · 0.85

Tested by

no test coverage detected