19#ifndef FREERDP_UTILS_POD_ARRAYS_H_ 
   20#define FREERDP_UTILS_POD_ARRAYS_H_ 
   22#include <winpr/wtypes.h> 
   23#include <winpr/assert.h> 
   30#define POD_ARRAYS_IMPL(T, TLOWER)                                                        \ 
   36  typedef BOOL Array##T##Cb(T* v, void* data);                                          \ 
   38  static inline void array_##TLOWER##_init(Array##T* a)                                 \ 
   45  static inline size_t array_##TLOWER##_size(const Array##T* a)                         \ 
   51  static inline T* array_##TLOWER##_data(const Array##T* a)                             \ 
   57  static inline const T* array_##TLOWER##_cdata(const Array##T* a)                      \ 
   60    return (const T*)a->values;                                                       \ 
   63  static inline T array_##TLOWER##_get(const Array##T* a, size_t idx)                   \ 
   66    WINPR_ASSERT(a->nvalues > idx);                                                   \ 
   67    return a->values[idx];                                                            \ 
   70  static inline void array_##TLOWER##_set(Array##T* a, size_t idx, T v)                 \ 
   73    WINPR_ASSERT(a->nvalues > idx);                                                   \ 
   77  static inline BOOL array_##TLOWER##_append(Array##T* a, T v)                          \ 
   80    T* tmp = realloc(a->values, sizeof(T) * (a->nvalues + 1));                        \ 
   84    tmp[a->nvalues] = v;                                                              \ 
   90  static inline BOOL array_##TLOWER##_contains(const Array##T* a, T v)                  \ 
   94    for (UINT32 i = 0; i < a->nvalues; i++)                                           \ 
   96      if (memcmp(&a->values[i], &v, sizeof(T)) == 0)                                \ 
  103  static inline BOOL array_##TLOWER##_foreach(Array##T* a, Array##T##Cb cb, void* data) \ 
  106    for (size_t i = 0; i < a->nvalues; i++)                                           \ 
  108      if (!cb(&a->values[i], data))                                                 \ 
  115  static inline void array_##TLOWER##_reset(Array##T* a)                                \ 
  121  static inline void array_##TLOWER##_uninit(Array##T* a)                               \ 
  130  POD_ARRAYS_IMPL(UINT16, uint16)
 
  131  POD_ARRAYS_IMPL(UINT32, uint32)
 
  132  POD_ARRAYS_IMPL(UINT64, uint64)