Add compilation test script

This commit is contained in:
Vinnie Falco
2013-09-27 17:13:36 -07:00
parent cc05ce19f9
commit 0b7574ba00
34 changed files with 343 additions and 241 deletions

View File

@@ -24,15 +24,21 @@
#ifndef BEAST_MEMORY_H_INCLUDED
#define BEAST_MEMORY_H_INCLUDED
#include <cstring>
#include "Config.h"
namespace beast {
//==============================================================================
/** Fills a block of memory with zeros. */
inline void zeromem (void* memory, size_t numBytes) noexcept { memset (memory, 0, numBytes); }
inline void zeromem (void* memory, size_t numBytes) noexcept
{ memset (memory, 0, numBytes); }
/** Overwrites a structure or object with zeros. */
template <typename Type>
inline void zerostruct (Type& structure) noexcept { memset (&structure, 0, sizeof (structure)); }
void zerostruct (Type& structure) noexcept
{ memset (&structure, 0, sizeof (structure)); }
/** Delete an object pointer, and sets the pointer to null.
@@ -40,26 +46,30 @@ inline void zerostruct (Type& structure) noexcept { memset (&s
or other automatic lifetime-management system rather than resorting to deleting raw pointers!
*/
template <typename Type>
inline void deleteAndZero (Type& pointer) { delete pointer; pointer = nullptr; }
void deleteAndZero (Type& pointer)
{ delete pointer; pointer = nullptr; }
/** A handy function which adds a number of bytes to any type of pointer and returns the result.
This can be useful to avoid casting pointers to a char* and back when you want to move them by
a specific number of bytes,
*/
template <typename Type, typename IntegerType>
inline Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept { return (Type*) (((char*) pointer) + bytes); }
Type* addBytesToPointer (Type* pointer, IntegerType bytes) noexcept
{ return (Type*) (((char*) pointer) + bytes); }
/** A handy function which returns the difference between any two pointers, in bytes.
The address of the second pointer is subtracted from the first, and the difference in bytes is returned.
*/
template <typename Type1, typename Type2>
inline int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept { return (int) (((const char*) pointer1) - (const char*) pointer2); }
int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept
{ return (int) (((const char*) pointer1) - (const char*) pointer2); }
/** If a pointer is non-null, this returns a new copy of the object that it points to, or safely returns
nullptr if the pointer is null.
*/
template <class Type>
inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; }
Type* createCopyIfNotNull (const Type* pointer)
{ return pointer != nullptr ? new Type (*pointer) : nullptr; }
//==============================================================================
#if BEAST_MAC || BEAST_IOS || DOXYGEN