struct hashtable * create_hashtable(unsigned int minsize, uint32_t (*hashfn) (String key), boolean (*eqfn) (const String str1, const String str2)) { struct hashtable *h; unsigned int pindex, size = primes[0]; /* Check requested hashtable isn't too large */ if (minsize > MAX_HASH_TABLE_SIZE) return NULL; /* Enforce size as prime */ for (pindex=0; pindex < prime_table_length; pindex++) { if (primes[pindex] >= minsize) { size = primes[pindex]; break; } } h = (struct hashtable *)EXIP_MALLOC(sizeof(struct hashtable)); if (NULL == h) return NULL; /*oom*/ h->table = (struct entry **)EXIP_MALLOC(sizeof(struct entry*) * size); if (NULL == h->table) { EXIP_MFREE(h); return NULL; } /*oom*/ memset(h->table, 0, size * sizeof(struct entry *)); h->tablelength = size; h->primeindex = pindex; h->entrycount = 0; h->hashfn = hashfn; h->eqfn = eqfn; h->loadlimit = CEIL(size * max_load_factor); return h; }
errorCode allocateStringMemory(CharType** str, Index UCSchars) { *str = EXIP_MALLOC(sizeof(CharType)*UCSchars); if((*str) == NULL) return EXIP_MEMORY_ALLOCATION_ERROR; return EXIP_OK; }
static int hashtable_expand(struct hashtable *h) { /* Double the size of the table to accommodate more entries */ struct entry **newtable; struct entry *e; struct entry **pE; unsigned int newsize, i, index; /* Check we're not hitting max capacity */ if (h->primeindex == (prime_table_length - 1) || primes[h->primeindex + 1] > MAX_HASH_TABLE_SIZE) return 0; newsize = primes[++(h->primeindex)]; newtable = (struct entry **)EXIP_MALLOC(sizeof(struct entry*) * newsize); if (NULL != newtable) { memset(newtable, 0, newsize * sizeof(struct entry *)); /* This algorithm is not 'stable'. ie. it reverses the list * when it transfers entries between the tables */ for (i = 0; i < h->tablelength; i++) { while (NULL != (e = h->table[i])) { h->table[i] = e->next; index = indexFor(newsize,e->hash); e->next = newtable[index]; newtable[index] = e; } } EXIP_MFREE(h->table); h->table = newtable; } /* Plan B: realloc instead */ else { newtable = (struct entry **) EXIP_REALLOC(h->table, newsize * sizeof(struct entry *)); if (NULL == newtable) { (h->primeindex)--; return 0; } h->table = newtable; memset(newtable[h->tablelength], 0, newsize - h->tablelength); for (i = 0; i < h->tablelength; i++) { for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE) { index = indexFor(newsize,e->hash); if (index == i) { pE = &(e->next); } else { *pE = e->next; e->next = newtable[index]; newtable[index] = e; } } } } h->tablelength = newsize; h->loadlimit = CEIL(newsize * max_load_factor); return -1; }
errorCode createPfxTable(PfxTable** pfxTable) { // Due to the small size of the prefix table, there is no need to // use a DynArray (*pfxTable) = (PfxTable*) EXIP_MALLOC(sizeof(PfxTable)); if(*pfxTable == NULL) return EXIP_MEMORY_ALLOCATION_ERROR; (*pfxTable)->count = 0; return EXIP_OK; }
errorCode cloneString(const String* src, String* newStr) { if(newStr == NULL) return EXIP_NULL_POINTER_REF; newStr->str = EXIP_MALLOC(sizeof(CharType)*src->length); if(newStr->str == NULL) return EXIP_MEMORY_ALLOCATION_ERROR; newStr->length = src->length; memcpy(newStr->str, src->str, src->length); return EXIP_OK; }
errorCode initAllocList(AllocList* list) { list->firstBlock = EXIP_MALLOC(sizeof(struct allocBlock)); if(list->firstBlock == NULL) return MEMORY_ALLOCATION_ERROR; list->firstBlock->nextBlock = NULL; list->lastBlock = list->firstBlock; list->currAllocSlot = 0; return ERR_OK; }
errorCode pushGrammar(EXIGrammarStack** gStack, EXIGrammar* grammar) { struct GrammarStackNode* node = (struct GrammarStackNode*)EXIP_MALLOC(sizeof(struct GrammarStackNode)); if(node == NULL) return MEMORY_ALLOCATION_ERROR; node->grammar = grammar; node->lastNonTermID = GR_VOID_NON_TERMINAL; node->nextInStack = *gStack; *gStack = node; return ERR_OK; }
void* memManagedAllocate(AllocList* list, size_t size) { void* ptr = EXIP_MALLOC(size); if(ptr != NULL) { if(list->currAllocSlot == ALLOCATION_ARRAY_SIZE) { struct allocBlock* newBlock = EXIP_MALLOC(sizeof(struct allocBlock)); if(newBlock == NULL) return NULL; newBlock->nextBlock = NULL; list->lastBlock->nextBlock = newBlock; list->lastBlock = newBlock; list->currAllocSlot = 0; } list->lastBlock->allocation[list->currAllocSlot] = ptr; list->currAllocSlot += 1; } return ptr; }
errorCode createDynArray(DynArray* dynArray, size_t entrySize, uint16_t chunkEntries) { void** base = (void **)(dynArray + 1); Index* count = (Index*)(base + 1); *base = EXIP_MALLOC(entrySize*chunkEntries); if(*base == NULL) return MEMORY_ALLOCATION_ERROR; dynArray->entrySize = entrySize; *count = 0; dynArray->chunkEntries = chunkEntries; dynArray->arrayEntries = chunkEntries; return ERR_OK; }
errorCode decodeBinary(EXIStream* strm, char** binary_val, Index* nbytes) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; UnsignedInteger length = 0; unsigned int int_val = 0; UnsignedInteger i = 0; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (binary)")); TRY(decodeUnsignedInteger(strm, &length)); *nbytes = (Index) length; (*binary_val) = (char*) EXIP_MALLOC(length); // This memory should be manually freed after the content handler is invoked if((*binary_val) == NULL) return EXIP_MEMORY_ALLOCATION_ERROR; for(i = 0; i < length; i++) { TRY_CATCH(readBits(strm, 8, &int_val), EXIP_MFREE(*binary_val)); (*binary_val)[i]=(char) int_val; } return EXIP_OK; }
errorCode hashtable_insert(struct hashtable *h, String key, Index value) { /* This method allows duplicate keys - but they shouldn't be used */ unsigned int index; struct entry *e; if (++(h->entrycount) > h->loadlimit) { /* Ignore the return value. If expand fails, we should * still try cramming just this value into the existing table * -- we may not have memory for a larger table, but one more * element may be ok. Next time we insert, we'll try expanding again.*/ hashtable_expand(h); } e = (struct entry *)EXIP_MALLOC(sizeof(struct entry)); if (NULL == e) { --(h->entrycount); return EXIP_MEMORY_ALLOCATION_ERROR; } /*oom*/ e->hash = h->hashfn(key); // hash(h,k, len); index = indexFor(h->tablelength,e->hash); e->key = key; e->value = value; e->next = h->table[index]; h->table[index] = e; return EXIP_OK; }
/** * Sorts the pre-populated entries in the string tables according to the spec. */ static void sortUriTable(UriTable* uriTable); errorCode generateSchemaInformedGrammars(BinaryBuffer* buffers, unsigned int bufCount, SchemaFormat schemaFormat, EXIOptions* opt, EXIPSchema* schema, errorCode (*loadSchemaHandler) (String* namespace, String* schemaLocation, BinaryBuffer** buffers, unsigned int* bufCount, SchemaFormat* schemaFormat, EXIOptions** opt)) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; TreeTable* treeT; unsigned int treeTCount = bufCount; unsigned int i = 0; // TODO: again in error cases all the memory must be released treeT = (TreeTable*) EXIP_MALLOC(sizeof(TreeTable)*bufCount); if(treeT == NULL) return EXIP_MEMORY_ALLOCATION_ERROR; for(i = 0; i < bufCount; i++) { TRY(initTreeTable(&treeT[i])); } TRY(initSchema(schema, INIT_SCHEMA_SCHEMA_ENABLED)); for(i = 0; i < bufCount; i++) { TRY(generateTreeTable(buffers[i], schemaFormat, opt, &treeT[i], schema)); }
errorCode createBuiltInElementGrammar(EXIGrammar* elementGrammar, EXIStream* strm) { unsigned int tmp_code1 = 0; // the number of productions with event codes with length 1 unsigned int tmp_code2 = 0; // the number of productions with event codes with length 2 unsigned int tmp_code3 = 0; // the number of productions with event codes with length 3 DynGrammarRule* tmp_rule; unsigned int p = 1; elementGrammar->count = DEF_ELEMENT_GRAMMAR_RULE_NUMBER; elementGrammar->props = 0; SET_BUILT_IN_ELEM(elementGrammar->props); SET_AUGMENTED(elementGrammar->props); elementGrammar->contentIndex = 0; elementGrammar->rule = (GrammarRule*) EXIP_MALLOC(sizeof(DynGrammarRule)*DEF_ELEMENT_GRAMMAR_RULE_NUMBER); if(elementGrammar->rule == NULL) return MEMORY_ALLOCATION_ERROR; /* Rule for StartTagContent */ /* StartTagContent : * EE 0.0 * AT (*) StartTagContent 0.1 * NS StartTagContent 0.2 * SC Fragment 0.3 * SE (*) ElementContent 0.4 * CH ElementContent 0.5 * ER ElementContent 0.6 * CM ElementContent 0.7.0 * PI ElementContent 0.7.1 */ tmp_rule = &((DynGrammarRule*) elementGrammar->rule)[GR_START_TAG_CONTENT]; /* Initialize Part 2 */ tmp_rule->part[1].prod = NULL; tmp_rule->part[1].count = 0; tmp_rule->part[1].bits = 0; /* Initialize Part 3 */ tmp_rule->part[2].prod = NULL; tmp_rule->part[2].count = 0; tmp_rule->part[2].bits = 0; tmp_code1 = 0; tmp_code2 = 4; tmp_code3 = 0; /* Part 1 */ tmp_rule->part[0].prod = (Production*) EXIP_MALLOC(sizeof(Production)*DEFAULT_PROD_ARRAY_DIM); if(tmp_rule->part[0].prod == NULL) return MEMORY_ALLOCATION_ERROR; /* The part 1 productions get added later... */ tmp_rule->part[0].count = 0; tmp_rule->part[0].bits = 0; tmp_rule->part0Dimension = DEFAULT_PROD_ARRAY_DIM; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PREFIXES)) tmp_code2 += 1; if(WITH_SELF_CONTAINED(strm->header.opts.enumOpt)) tmp_code2 += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_DTD)) tmp_code2 += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_COMMENTS)) tmp_code3 += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PIS)) tmp_code3 += 1; /* Part 2 */ tmp_rule->part[1].prod = (Production*) EXIP_MALLOC(sizeof(Production)*tmp_code2); if(tmp_rule->part[1].prod == NULL) return MEMORY_ALLOCATION_ERROR; /* EE 0.0 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_EE; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_VOID_NON_TERMINAL; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; /* AT (*) StartTagContent 0.1 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_AT_ALL; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_START_TAG_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PREFIXES)) { /* NS StartTagContent 0.2 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_NS; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_START_TAG_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; } if(WITH_SELF_CONTAINED(strm->header.opts.enumOpt)) { /* SC Fragment 0.3 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_SC; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_FRAGMENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; } /* SE (*) ElementContent 0.2 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_SE_ALL; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; /* CH ElementContent 0.3 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_CH; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_DTD)) { /* ER ElementContent 0.6 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_ER; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; } tmp_rule->part[1].count = tmp_code2; tmp_rule->part[1].bits = getBitsNumber(tmp_code2 - 1 + (tmp_code3 > 0)); /* Part 3 */ if(tmp_code3 > 0) { p = 1; tmp_rule->part[2].prod = (Production*) EXIP_MALLOC(sizeof(Production)*tmp_code3); if(tmp_rule->part[2].prod == NULL) return MEMORY_ALLOCATION_ERROR; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_COMMENTS)) { /* CM ElementContent 0.7.0 */ tmp_rule->part[2].prod[tmp_code3-p].eventType = EVENT_CM; tmp_rule->part[2].prod[tmp_code3-p].typeId = INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[2].prod[tmp_code3-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].qnameId.lnId = INDEX_MAX; p += 1; } if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PIS)) { /* PI ElementContent 0.7.1 */ tmp_rule->part[2].prod[tmp_code3-p].eventType = EVENT_PI; tmp_rule->part[2].prod[tmp_code3-p].typeId = INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[2].prod[tmp_code3-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].qnameId.lnId = INDEX_MAX; } tmp_rule->part[2].count = tmp_code3; tmp_rule->part[2].bits = tmp_code3 > 1; } p = 1; /* Rule for ElementContent */ /* ElementContent : * EE 0 * SE (*) ElementContent 1.0 * CH ElementContent 1.1 * ER ElementContent 1.2 * CM ElementContent 1.3.0 * PI ElementContent 1.3.1 */ tmp_rule = &((DynGrammarRule*) elementGrammar->rule)[GR_ELEMENT_CONTENT]; /* Initialize Part 2 */ tmp_rule->part[1].prod = NULL; tmp_rule->part[1].count = 0; tmp_rule->part[1].bits = 0; /* Initialize Part 3 */ tmp_rule->part[2].prod = NULL; tmp_rule->part[2].count = 0; tmp_rule->part[2].bits = 0; tmp_code1 = 1; tmp_code2 = 2; tmp_code3 = 0; /* Part 1 */ tmp_rule->part[0].prod = (Production*) EXIP_MALLOC(sizeof(Production)*DEFAULT_PROD_ARRAY_DIM); if(tmp_rule->part[0].prod == NULL) return MEMORY_ALLOCATION_ERROR; /* EE 0 */ tmp_rule->part[0].prod[0].eventType = EVENT_EE; tmp_rule->part[0].prod[0].typeId = INDEX_MAX; tmp_rule->part[0].prod[0].nonTermID = GR_VOID_NON_TERMINAL; tmp_rule->part[0].prod[0].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[0].prod[0].qnameId.lnId = INDEX_MAX; tmp_rule->part[0].count = 1; tmp_rule->part[0].bits = 1; tmp_rule->part0Dimension = DEFAULT_PROD_ARRAY_DIM; /* More part 1 productions get added later... */ if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_DTD)) tmp_code2 += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_COMMENTS)) tmp_code3 += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PIS)) tmp_code3 += 1; /* Part 2 */ tmp_rule->part[1].prod = (Production*) EXIP_MALLOC(sizeof(Production)*tmp_code2); if(tmp_rule->part[1].prod == NULL) return MEMORY_ALLOCATION_ERROR; /* SE (*) ElementContent 1.0 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_SE_ALL; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; /* CH ElementContent 1.1 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_CH; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; p += 1; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_DTD)) { /* ER ElementContent 1.2 */ tmp_rule->part[1].prod[tmp_code2-p].eventType = EVENT_ER; tmp_rule->part[1].prod[tmp_code2-p].typeId = INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[1].prod[tmp_code2-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[1].prod[tmp_code2-p].qnameId.lnId = INDEX_MAX; } tmp_rule->part[1].count = tmp_code2; tmp_rule->part[1].bits = 1 + ((tmp_code2 - 2 + tmp_code3) > 0); /* Part 3 */ if(tmp_code3 > 0) { p = 1; tmp_rule->part[2].prod = (Production*) EXIP_MALLOC(sizeof(Production)*tmp_code3); if(tmp_rule->part[2].prod == NULL) return MEMORY_ALLOCATION_ERROR; if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_COMMENTS)) { /* CM ElementContent 1.3.0 */ tmp_rule->part[2].prod[tmp_code3-p].eventType = EVENT_CM; tmp_rule->part[2].prod[tmp_code3-p].typeId = INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[2].prod[tmp_code3-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].qnameId.lnId = INDEX_MAX; p += 1; } if(IS_PRESERVED(strm->header.opts.preserve, PRESERVE_PIS)) { /* PI ElementContent 1.3.1 */ tmp_rule->part[2].prod[tmp_code3-p].eventType = EVENT_PI; tmp_rule->part[2].prod[tmp_code3-p].typeId = INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].nonTermID = GR_ELEMENT_CONTENT; tmp_rule->part[2].prod[tmp_code3-p].qnameId.uriId = SMALL_INDEX_MAX; tmp_rule->part[2].prod[tmp_code3-p].qnameId.lnId = INDEX_MAX; } tmp_rule->part[2].count = tmp_code3; tmp_rule->part[2].bits = tmp_code3 > 1; } return ERR_OK; }
errorCode createBuiltInElementGrammar(EXIGrammar* elementGrammar, EXIStream* strm) { DynGrammarRule* tmp_rule; elementGrammar->count = DEF_ELEMENT_GRAMMAR_RULE_NUMBER; elementGrammar->props = 0; SET_BUILT_IN_ELEM_GR(elementGrammar->props); elementGrammar->rule = (GrammarRule*) EXIP_MALLOC(sizeof(DynGrammarRule)*DEF_ELEMENT_GRAMMAR_RULE_NUMBER); if(elementGrammar->rule == NULL) return MEMORY_ALLOCATION_ERROR; /* Rule for StartTagContent */ /* StartTagContent : * EE 0.0 * AT (*) StartTagContent 0.1 * NS StartTagContent 0.2 * SC Fragment 0.3 * SE (*) ElementContent 0.4 * CH ElementContent 0.5 * ER ElementContent 0.6 * CM ElementContent 0.7.0 * PI ElementContent 0.7.1 */ tmp_rule = &((DynGrammarRule*) elementGrammar->rule)[GR_START_TAG_CONTENT]; /* Part 1 */ tmp_rule->production = (Production*) EXIP_MALLOC(sizeof(Production)*DEFAULT_PROD_ARRAY_DIM); if(tmp_rule->production == NULL) return MEMORY_ALLOCATION_ERROR; /* The part 1 productions get added later... */ tmp_rule->pCount = 0; tmp_rule->meta = 0; tmp_rule->prodDim = DEFAULT_PROD_ARRAY_DIM; /* Rule for ElementContent */ /* ElementContent : * EE 0 * SE (*) ElementContent 1.0 * CH ElementContent 1.1 * ER ElementContent 1.2 * CM ElementContent 1.3.0 * PI ElementContent 1.3.1 */ tmp_rule = &((DynGrammarRule*) elementGrammar->rule)[GR_ELEMENT_CONTENT]; /* Part 1 */ tmp_rule->production = (Production*) EXIP_MALLOC(sizeof(Production)*DEFAULT_PROD_ARRAY_DIM); if(tmp_rule->production == NULL) return MEMORY_ALLOCATION_ERROR; /* EE 0 */ SET_PROD_EXI_EVENT(tmp_rule->production[0].content, EVENT_EE); SET_PROD_NON_TERM(tmp_rule->production[0].content, GR_VOID_NON_TERMINAL); tmp_rule->production[0].typeId = INDEX_MAX; tmp_rule->production[0].qnameId.uriId = URI_MAX; tmp_rule->production[0].qnameId.lnId = LN_MAX; tmp_rule->pCount = 1; tmp_rule->prodDim = DEFAULT_PROD_ARRAY_DIM; /* More part 1 productions get added later... */ return ERR_OK; }