• E
    alloc: make VIR_APPEND_ELEMENT safer · ddcfc549
    Eric Blake 提交于
    VIR_APPEND_ELEMENT(array, size, elem) was not safe if the expression
    for 'size' had side effects.  While no one in the current code base
    was trying to pass side effects, we might as well be robust and
    explicitly document our intentions.
    
    * src/util/viralloc.c (virInsertElementsN): Add special case.
    * src/util/viralloc.h (VIR_APPEND_ELEMENT): Use it.
    (VIR_ALLOC, VIR_ALLOC_N, VIR_REALLOC_N, VIR_EXPAND_N)
    (VIR_RESIZE_N, VIR_SHRINK_N, VIR_INSERT_ELEMENT)
    (VIR_DELETE_ELEMENT, VIR_ALLOC_VAR, VIR_FREE): Document
    which macros are safe in the presence of side effects.
    * docs/hacking.html.in: Document this.
    * HACKING: Regenerate.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    ddcfc549
viralloc.c 13.1 KB