astropy/utils/xml/src/iterparse.c
/**
 * Extend the tuple queue based on the new length of the textual XML input.
 * This helps to cope with situations where the input is longer than
 * requested (as occurs with transparent decompression of the input
 * stream), and for the initial allocation to combine the logic in one place.
 */
Extend the tuple queue based on the new length of the textual XML input.
This helps to cope with situations where the input is longer than
requested (as occurs with transparent decompression of the input
stream), and for the initial allocation to combine the logic in one place.
Extend the tuple queue based on the new length of the textual XML input . This helps to cope with situations where the input is longer than requested ( as occurs with transparent decompression of the input stream ) and for the initial allocation to combine the logic in one place .
static int
queue_realloc(IterParser *self, Py_ssize_t req_size)
{
    PyObject** new_queue;
    Py_ssize_t n = req_size / 2;
    if (n <= self->queue_size)
        return 0;
    new_queue = realloc(self->queue, sizeof(PyObject*) * (size_t)n);
    if (new_queue == NULL) {
        PyErr_SetString(PyExc_MemoryError, "Out of memory for XML parsing queue.");
        goto fail;
    }
    self->queue = new_queue;
    self->queue_size = n;
    return 0;
fail:
    free(self->queue);
    self->queue = NULL;
    self->queue_size = 0;
    return -1;
}
static int queue_realloc ( IterParser * self , Py_ssize_t req_size ) { PyObject * * new_queue ; Py_ssize_t n = req_size / 2 ; if ( n <= self -> queue_size ) return 0 ; new_queue = realloc ( self -> queue , sizeof ( PyObject * ) * ( size_t ) n ) ; if ( new_queue == NULL ) { PyErr_SetString ( PyExc_MemoryError , " " ) ; goto fail ; } self -> queue = new_queue ; self -> queue_size = n ; return 0 ; fail : free ( self -> queue ) ; self -> queue = NULL ; self -> queue_size = 0 ; return -1 ; }
Extend the tuple queue based on the new length of the textual XML input.
Extend the tuple queue based on the new length of the textual XML input .
/*
         * queue_realloc() is only called from IterParser_init() or
         * IterParser_next() in situations where the queue is clear
         * and empty.  If this function were to be used in other
         * situations it would be wise to iterate over the queue and
         * clear/decrement the individual references, to save work for
         * the garbage collector (in an out-of-memory situation).
         */