Embperl
view release on metacpan or search on metacpan
/*in*/ tRepeatLevel nRepeatLevel,
/*in*/ tIndex * pxChilds,
/*in*/ tSInt32 nLinenumber,
/*in*/ tSInt32 nSize)
{
tIndex xChilds = pxChilds?*pxChilds:0 ;
tNodeData * pNewChild ;
tIndex xNdx = ArrayAdd (a, &pDomTree -> pLookup, 1) ;
if (nSize == 0)
nSize = sizeof (tNodeData) ;
if ((pDomTree -> pLookup[xNdx].pLookup = pNewChild = dom_malloc (a, nSize, &numNodes)) == NULL)
return NULL ;
pDomTree -> pLookup[xNdx].pLookupLevel = NULL ;
memset (pNewChild, 0, nSize) ;
pNewChild -> xParent = xParent ;
pNewChild -> xNdx = xNdx ;
pNewChild -> nLinenumber = (tUInt16)nLinenumber ;
pNewChild -> bFlags = nflgOK ;
pNewChild -> xDomTree = pDomTree -> xNdx ;
pNewChild -> nRepeatLevel = nRepeatLevel ;
if (xChilds)
{ /* --- attribute has already children, get the first and last one --- */
tNodeData * pFirstChild = Node_selfLevel (a, pDomTree, xChilds, nRepeatLevel) ;
tNodeData * pLastChild = Node_selfLevel (a, pDomTree, pFirstChild -> xPrev, nRepeatLevel) ;
pFirstChild = Node_selfCondCloneNode (a, pDomTree, pFirstChild, nRepeatLevel) ;
pLastChild = Node_selfCondCloneNode (a, pDomTree, pLastChild, nRepeatLevel) ;
pNewChild -> xNext = pFirstChild -> xNdx ;
pNewChild -> xPrev = pLastChild -> xNdx ;
pFirstChild -> xPrev = xNdx ;
pLastChild -> xNext = xNdx ;
}
else
/* --- attribute has no children, get a new one --- */
{
pNewChild -> xPrev = xNdx ;
pNewChild -> xNext = xNdx ;
if (pxChilds)
*pxChilds = xNdx ;
}
return pNewChild ;
}
/* ------------------------------------------------------------------------ */
/* */
/* Node_selfExpand */
/* */
/*!
* \_en
* Expand a node to hold more attributes
*
* @param pNode Node to expand
* @param numOldAttr number of Attributes in the old node that must
* be relocated (-1 to take form pNode)
* @param numNewAttr new number of attributes
* @return The node with space for numNewAttr
*
* @warning The node may have a new memory address after this function
* \endif
*
* \_de
* Expandiert einen Node um mehr Attribute aufzunehmen
*
* @param pNode Node der expandiert werden soll
* @param numOldAttr Anzahl der Attribute die Relokiert werden m?ssen
* (-1 um alle Attribute zu relokieren)
* @param numNewAttr Neue Anzahl der Attribute
* @return Den Node mit platz f?r numNewAttr
*
* @warning Der Node liegt nach dem Aufruf dieser Funktion u.U. an
* anderen Speicheradresse
* \endif
*
* ------------------------------------------------------------------------ */
tNodeData * Node_selfExpand (/*in*/ tApp * a,
/*in*/ tDomTree * pDomTree,
/*in*/ tNodeData * pNode,
/*in*/ tUInt16 numOldAttr,
/*in*/ tUInt16 numNewAttr)
{
tNodeData * pNewChild ;
tNode xNdx = pNode -> xNdx ;
int nSize = sizeof (tNodeData) + numNewAttr * sizeof (tAttrData) ;
if ((pNewChild = dom_realloc (a, pNode, nSize)) == NULL)
return NULL ;
if (pNewChild != pNode)
{
tAttrData * pAttr = ((struct tAttrData * )(pNewChild + 1)) ;
tLookupItem * pLookup = pDomTree -> pLookup ;
tRepeatLevelLookup *pLookupLevelNode= pLookup[xNdx].pLookupLevel ;
if (numOldAttr == (tUInt16) -1)
numOldAttr = pNewChild -> numAttr ;
pLookup[xNdx].pLookup = pNewChild ;
if (pLookupLevelNode)
{
tRepeatLevel nLevel = pNewChild -> nRepeatLevel ;
register tRepeatLevelLookupItem * pLookupLevelNodeLevel = &pLookupLevelNode -> items[nLevel & pLookupLevelNode -> nMask] ;
register tNodeData * pLnNode = pLookupLevelNodeLevel -> pNode ;
if (pLnNode && pLnNode -> nRepeatLevel == nLevel)
pLookupLevelNodeLevel -> pNode = pNewChild ;
else
{
while ((pLookupLevelNodeLevel = pLookupLevelNodeLevel -> pNext))
{
pLnNode = pLookupLevelNodeLevel -> pNode ;
( run in 0.892 second using v1.01-cache-2.11-cpan-71847e10f99 )