r6:Function:abstraction aligned free

From liblfds.org
Revision as of 14:07, 4 January 2015 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source Files

/src/abstraction/abstraction_aligned_free.c
/inc/liblfds.h

Prototype

void abstraction_aligned_free( void *memory );

Parameters

void *memory

Pointer to memory previously allocated by abstraction_aligned_malloc.

Return Value

No return value.

Notes

Some platforms (such as Windows) have a particular free function (as opposed to the normal free function) which must be used in conjunction with the aligned malloc function. Others (such as Linux) do not and the normal free function can be used.

Examples

Under Windows (32-bit and 64-bit), using the Microsoft C compiler, there is a particular function _aligned_free which must be used with memory allocated by the aligned memory allocator and this free function has the following prototype;

void _aligned_free( void *memblock );

As such, the implementation of abstraction_aligned_free() on all Windows (user-mode), for all CPUs, using the Microsoft C compiler, looks like this;

#if (defined _WIN32 && defined _MSC_VER && !defined WIN_KERNEL_BUILD)

  /* TRD : any Windows on any CPU with the Microsoft C compiler

           _WIN32             indicates 64-bit or 32-bit Windows
           _MSC_VER           indicates Microsoft C compiler
           !WIN_KERNEL_BUILD  indicates Windows user-mode
  */

  void abstraction_aligned_free( void *memory )
  {
    _aligned_free( memory );

    return;
  }

#endif

See Also