ucif/antlr3/src/antlr3collections.c
static  ANTLR3_UINT32
antlr3VectorSet     (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry, void * element, void (ANTLR3_CDECL *freeptr)(void *), ANTLR3_BOOLEAN freeExisting)
{

        // If the vector is currently not big enough, then we expand it
        //
        if (entry >= vector->elementsSize)
        {
                // We will get at least this many
                if (!antlr3VectorResize(vector, entry))
                {
                        // Resize failed
                        return 0;
                }
        }

        // Valid request, replace the current one, freeing any prior entry if told to
        //
        if      (               entry < vector->count                                           // If actually replacing an element
                        &&      freeExisting                                                            // And told to free any existing element
                        &&      vector->elements[entry].freeptr != NULL         // And the existing element has a free pointer
                )
        {
                vector->elements[entry].freeptr(vector->elements[entry].element);
        }

        // Install the new pointers
        //
        vector->elements[entry].freeptr = freeptr;
        vector->elements[entry].element = element;

        if (entry >= vector->count)
        {
                vector->count = entry + 1;
        }
        return  (ANTLR3_UINT32)(entry);     // Indicates the replacement was successful

}
/// Replace the element at the specified entry point with the supplied
/// entry.
///
Replace the element at the specified entry point with the supplied
entry.
Replace the element at the specified entry point with the supplied entry .
static  ANTLR3_UINT32
antlr3VectorSet     (pANTLR3_VECTOR vector, ANTLR3_UINT32 entry, void * element, void (ANTLR3_CDECL *freeptr)(void *), ANTLR3_BOOLEAN freeExisting)
{
        if (entry >= vector->elementsSize)
        {
                 We will get at least this many
                if (!antlr3VectorResize(vector, entry))
                {
                         Resize failed
                        return 0;
                }
        }
         Valid request, replace the current one, freeing any prior entry if told to
        if      (               entry < vector->count                                            If actually replacing an element
                        &&      freeExisting                                                             And told to free any existing element
                        &&      vector->elements[entry].freeptr != NULL          And the existing element has a free pointer
                )
        {
                vector->elements[entry].freeptr(vector->elements[entry].element);
        }
         Install the new pointers
        vector->elements[entry].freeptr = freeptr;
        vector->elements[entry].element = element;
        if (entry >= vector->count)
        {
                vector->count = entry + 1;
        }
        return  (ANTLR3_UINT32)(entry);      Indicates the replacement was successful
}
static ANTLR3_UINT32 antlr3VectorSet ( pANTLR3_VECTOR vector , ANTLR3_UINT32 entry , void * element , void ( ANTLR3_CDECL * freeptr ) ( void * ) , ANTLR3_BOOLEAN freeExisting ) { if ( entry >= vector -> elementsSize ) { if ( ! antlr3VectorResize ( vector , entry ) ) { return 0 ; } } if ( entry < vector -> count && freeExisting && vector -> elements [ entry ] . freeptr != NULL ) { vector -> elements [ entry ] . freeptr ( vector -> elements [ entry ] . element ) ; } vector -> elements [ entry ] . freeptr = freeptr ; vector -> elements [ entry ] . element = element ; if ( entry >= vector -> count ) { vector -> count = entry + 1 ; } return ( ANTLR3_UINT32 ) ( entry ) ; }
Replace the element at the specified entry point with the supplied
entry.
Replace the element at the specified entry point with the supplied entry .
// If the vector is currently not big enough, then we expand it // // We will get at least this many // Resize failed // Valid request, replace the current one, freeing any prior entry if told to // // If actually replacing an element // And told to free any existing element // And the existing element has a free pointer // Install the new pointers // // Indicates the replacement was successful