• E
    maint: avoid 'const fooPtr' in hashes · b43efdaa
    Eric Blake 提交于
    'const fooPtr' is the same as 'foo * const' (the pointer won't
    change, but it's contents can).  But in general, if an interface
    is trying to be const-correct, it should be using 'const foo *'
    (the pointer is to data that can't be changed).
    
    Fix up virhash to provide a const-correct interface: all actions
    that don't modify the table take a const table.  Note that in
    one case (virHashSearch), we actually strip const away - we aren't
    modifying the contents of the table, so much as associated data
    for ensuring that the code uses the table correctly (if this were
    C++, it would be a case for the 'mutable' keyword).
    
    * src/util/virhash.h (virHashKeyComparator, virHashEqual): Use
    intended type.
    (virHashSize, virHashTableSize, virHashLookup, virHashSearch):
    Make const-correct.
    * src/util/virhash.c (virHashEqualData, virHashEqual)
    (virHashLookup, virHashSize, virHashTableSize, virHashSearch)
    (virHashComputeKey): Fix fallout.
    * src/conf/nwfilter_params.c
    (virNWFilterFormatParameterNameSorter): Likewise.
    * src/nwfilter/nwfilter_ebiptables_driver.c
    (ebiptablesFilterOrderSort): Likewise.
    * tests/virhashtest.c (testHashGetItemsCompKey)
    (testHashGetItemsCompValue): Likewise.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    b43efdaa
virhash.c 17.6 KB