OpenVPN
Macros | Functions
cmocka_private.h File Reference
#include <stdint.h>
#include <windows.h>
Include dependency graph for cmocka_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PRIdS   "Id"
 
#define PRIu64   "I64u"
 
#define PRIuMAX   PRIu64
 
#define PRIxMAX   "I64x"
 
#define PRIXMAX   "I64X"
 
#define SAFE_FREE(x)   do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
 Free memory space. More...
 
#define ZERO_STRUCT(x)   memset((char *)&(x), 0, sizeof(x))
 Zero a structure. More...
 
#define ZERO_STRUCTP(x)   do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
 Zero a structure given a pointer to the structure. More...
 
#define ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
 Get the size of an array. More...
 
#define BURN_STRING(x)   do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0)
 Overwrite the complete string with 'X'. More...
 
#define discard_const(ptr)   ((void *)((uintptr_t)(ptr)))
 This is a hack to fix warnings. More...
 
#define discard_const_p(type, ptr)   ((type *)discard_const(ptr))
 Type-safe version of discard_const. More...
 

Functions

WINBASEAPI BOOL WINAPI IsDebuggerPresent (VOID)
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a)/sizeof(a[0]))

Get the size of an array.

Definition at line 139 of file cmocka_private.h.

Referenced by _run_test(), _test_free(), cmocka_run_one_test_or_fixture(), and exception_filter().

◆ BURN_STRING

#define BURN_STRING (   x)    do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0)

Overwrite the complete string with 'X'.

Definition at line 142 of file cmocka_private.h.

◆ discard_const

#define discard_const (   ptr)    ((void *)((uintptr_t)(ptr)))

This is a hack to fix warnings.

The idea is to use this everywhere that we get the "discarding const" warning by the compiler. That doesn't actually fix the real issue, but marks the place and you can search the code for discard_const.

Please use this macro only when there is no other way to fix the warning. We should use this function in only in a very few places.

Also, please call this via the discard_const_p() macro interface, as that makes the return type safe.

Definition at line 156 of file cmocka_private.h.

Referenced by _expect_not_string(), and _expect_string().

◆ discard_const_p

#define discard_const_p (   type,
  ptr 
)    ((type *)discard_const(ptr))

Type-safe version of discard_const.

Definition at line 161 of file cmocka_private.h.

Referenced by _cmocka_run_group_tests(), _test_free(), and free_allocated_blocks().

◆ PRIdS

#define PRIdS   "Id"

◆ PRIu64

#define PRIu64   "I64u"

◆ PRIuMAX

#define PRIuMAX   PRIu64

Definition at line 86 of file cmocka_private.h.

◆ PRIxMAX

#define PRIxMAX   "I64x"

Definition at line 90 of file cmocka_private.h.

◆ PRIXMAX

#define PRIXMAX   "I64X"

Definition at line 94 of file cmocka_private.h.

◆ SAFE_FREE

#define SAFE_FREE (   x)    do { if ((x) != NULL) {free(x); x=NULL;} } while(0)

Free memory space.

Definition at line 130 of file cmocka_private.h.

◆ ZERO_STRUCT

#define ZERO_STRUCT (   x)    memset((char *)&(x), 0, sizeof(x))

Zero a structure.

Definition at line 133 of file cmocka_private.h.

◆ ZERO_STRUCTP

#define ZERO_STRUCTP (   x)    do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)

Zero a structure given a pointer to the structure.

Definition at line 136 of file cmocka_private.h.

Function Documentation

◆ IsDebuggerPresent()

WINBASEAPI BOOL WINAPI IsDebuggerPresent ( VOID  )