VirtualBox

Changeset 18424 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 28, 2009 1:40:40 AM (16 years ago)
Author:
vboxsync
Message:

iprt/string.h: Added the macros RT_ZERO(Obj) and RT_BZERO(pv, cb) for shortening memset(&Obj, 0, sizeof(Obj)) and memset(pv, 0, cb).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/string.h

    r16323 r18424  
    7272#endif
    7373
     74/**
     75 * Byte zero the specified object.
     76 *
     77 * This will use sizeof(Obj) to figure the size and will call memset, bzero
     78 * or some compiler intrinsic to perform the actual zeroing.
     79 *
     80 * @param   Obj     The object to zero. Make sure to dereference pointers.
     81 *
     82 * @remarks Because the macro may use memset it has been placed in string.h
     83 *          instead of cdefs.h to avoid build issues because someone forgot
     84 *          to include this header.
     85 *
     86 * @ingroup grp_rt_cdefs
     87 */
     88#define RT_ZERO(Obj)        RT_BZERO(&(Obj), sizeof(Obj))
     89
     90/**
     91 * Byte zero the specified memory area.
     92 *
     93 * This will call memset, bzero or some compiler intrinsic to clear the
     94 * specified bytes of memory.
     95 *
     96 * @param   pv          Pointer to the memory.
     97 * @param   cb          The number of bytes to clear. Please, don't pass 0.
     98 *
     99 * @remarks Because the macro may use memset it has been placed in string.h
     100 *          instead of cdefs.h to avoid build issues because someone forgot
     101 *          to include this header.
     102 *
     103 * @ingroup grp_rt_cdefs
     104 */
     105#define RT_BZERO(pv, cb)    do { memset((pv), 0, cb); } while (0)
     106
    74107
    75108/** @defgroup grp_rt_str    RTStr - String Manipulation
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette