• E
    string: make VIR_STRDUP easier to use · 6b74a9f5
    Eric Blake 提交于
    While reviewing proposed VIR_STRDUP conversions, I've already noticed
    several places that do:
    
    if (str && VIR_STRDUP(dest, str) < 0)
    
    which can be simplified by allowing str to be NULL (something that
    strdup() doesn't allow).  Meanwhile, code that wants to ensure a
    non-NULL dest regardless of the source can check for <= 0.
    
    Also, make it part of the VIR_STRDUP contract that macro arguments
    are evaluated exactly once.
    
    * src/util/virstring.h (VIR_STRDUP, VIR_STRDUP_QUIET, VIR_STRNDUP)
    (VIR_STRNDUP_QUIET): Improve contract.
    * src/util/virstring.c (virStrdup, virStrndup): Change return
    conventions.
    * docs/hacking.html.in: Document this.
    * HACKING: Regenerate.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    6b74a9f5
hacking.html.in 37.0 KB