MCPcopy Create free account
hub / github.com/Kitware/CMake / storeRawNames

Function storeRawNames

Utilities/cmexpat/lib/xmlparse.c:3122–3169  ·  view source on GitHub ↗

Initially tag->rawName always points into the parse buffer; for those TAG instances opened while the current parse buffer was processed, and not yet closed, we need to store tag->rawName in a more permanent location, since the parse buffer is about to be discarded. */

Source from the content-addressed store, hash-verified

3120 permanent location, since the parse buffer is about to be discarded.
3121*/
3122static XML_Bool
3123storeRawNames(XML_Parser parser) {
3124 TAG *tag = parser->m_tagStack;
3125 while (tag) {
3126 size_t bufSize;
3127 size_t nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
3128 size_t rawNameLen;
3129 char *rawNameBuf = tag->buf + nameLen;
3130 /* Stop if already stored. Since m_tagStack is a stack, we can stop
3131 at the first entry that has already been copied; everything
3132 below it in the stack is already been accounted for in a
3133 previous call to this function.
3134 */
3135 if (tag->rawName == rawNameBuf)
3136 break;
3137 /* For reuse purposes we need to ensure that the
3138 size of tag->buf is a multiple of sizeof(XML_Char).
3139 */
3140 rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
3141 /* Detect and prevent integer overflow. */
3142 if (rawNameLen > (size_t)INT_MAX - nameLen)
3143 return XML_FALSE;
3144 bufSize = nameLen + rawNameLen;
3145 if (bufSize > (size_t)(tag->bufEnd - tag->buf)) {
3146 char *temp = REALLOC(parser, tag->buf, bufSize);
3147 if (temp == NULL)
3148 return XML_FALSE;
3149 /* if tag->name.str points to tag->buf (only when namespace
3150 processing is off) then we have to update it
3151 */
3152 if (tag->name.str == (XML_Char *)tag->buf)
3153 tag->name.str = (XML_Char *)temp;
3154 /* if tag->name.localPart is set (when namespace processing is on)
3155 then update it as well, since it will always point into tag->buf
3156 */
3157 if (tag->name.localPart)
3158 tag->name.localPart
3159 = (XML_Char *)temp + (tag->name.localPart - (XML_Char *)tag->buf);
3160 tag->buf = temp;
3161 tag->bufEnd = temp + bufSize;
3162 rawNameBuf = temp + nameLen;
3163 }
3164 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength);
3165 tag->rawName = rawNameBuf;
3166 tag = tag->parent;
3167 }
3168 return XML_TRUE;
3169}
3170
3171static enum XML_Error PTRCALL
3172contentProcessor(XML_Parser parser, const char *start, const char *end,

Callers 2

contentProcessorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…