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

Function getContext

Utilities/cmexpat/lib/xmlparse.c:7308–7402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7306#define CONTEXT_SEP XML_T(ASCII_FF)
7307
7308static const XML_Char *
7309getContext(XML_Parser parser) {
7310 DTD *const dtd = parser->m_dtd; /* save one level of indirection */
7311 HASH_TABLE_ITER iter;
7312 XML_Bool needSep = XML_FALSE;
7313
7314 if (dtd->defaultPrefix.binding) {
7315 int i;
7316 int len;
7317 if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS)))
7318 return NULL;
7319 len = dtd->defaultPrefix.binding->uriLen;
7320 if (parser->m_namespaceSeparator)
7321 len--;
7322 for (i = 0; i < len; i++) {
7323 if (! poolAppendChar(&parser->m_tempPool,
7324 dtd->defaultPrefix.binding->uri[i])) {
7325 /* Because of memory caching, I don't believe this line can be
7326 * executed.
7327 *
7328 * This is part of a loop copying the default prefix binding
7329 * URI into the parser's temporary string pool. Previously,
7330 * that URI was copied into the same string pool, with a
7331 * terminating NUL character, as part of setContext(). When
7332 * the pool was cleared, that leaves a block definitely big
7333 * enough to hold the URI on the free block list of the pool.
7334 * The URI copy in getContext() therefore cannot run out of
7335 * memory.
7336 *
7337 * If the pool is used between the setContext() and
7338 * getContext() calls, the worst it can do is leave a bigger
7339 * block on the front of the free list. Given that this is
7340 * all somewhat inobvious and program logic can be changed, we
7341 * don't delete the line but we do exclude it from the test
7342 * coverage statistics.
7343 */
7344 return NULL; /* LCOV_EXCL_LINE */
7345 }
7346 }
7347 needSep = XML_TRUE;
7348 }
7349
7350 hashTableIterInit(&iter, &(dtd->prefixes));
7351 for (;;) {
7352 int i;
7353 int len;
7354 const XML_Char *s;
7355 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter);
7356 if (! prefix)
7357 break;
7358 if (! prefix->binding) {
7359 /* This test appears to be (justifiable) paranoia. There does
7360 * not seem to be a way of injecting a prefix without a binding
7361 * that doesn't get errored long before this function is called.
7362 * The test should remain for safety's sake, so we instead
7363 * exclude the following line from the coverage statistics.
7364 */
7365 continue; /* LCOV_EXCL_LINE */

Callers 1

doContentFunction · 0.85

Calls 2

hashTableIterInitFunction · 0.85
hashTableIterNextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…