SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Defines | Functions
memory.cpp File Reference

Go to the source code of this file.

Defines

#define SG_SPECIALIZED_MALLOC(type)

Functions

void * operator new (size_t size) throw (std::bad_alloc)
void operator delete (void *p) throw ()
void * operator new[] (size_t size) throw (std::bad_alloc)
void operator delete[] (void *p) throw ()
void * sg_malloc (size_t size)
void * sg_calloc (size_t num, size_t size)
void sg_free (void *ptr)
void * sg_realloc (void *ptr, size_t size)

Define Documentation

#define SG_SPECIALIZED_MALLOC (   type)
Value:
template<> type* sg_generic_malloc<type >(size_t len)               \
{                                                                   \
    return new type[len]();                                         \
}                                                                   \
                                                                    \
template<> type* sg_generic_calloc<type >(size_t len)               \
{                                                                   \
    return new type[len]();                                         \
}                                                                   \
                                                                    \
template<> type* sg_generic_realloc<type >(type* ptr, size_t old_len, size_t len)   \
{                                                                   \
    type* new_ptr = new type[len]();                                \
    size_t min_len=old_len;                                         \
    if (len<min_len)                                                \
        min_len=len;                                                \
    for (size_t i=0; i<min_len; i++)                                \
        new_ptr[i]=ptr[i];                                          \
    delete[] ptr;                                                   \
    return new_ptr;                                                 \
}                                                                   \
                                                                    \
template<> void sg_generic_free<type >(type* ptr)                   \
{                                                                   \
    delete[] ptr;                                                   \
}

Definition at line 367 of file memory.cpp.


Function Documentation

void operator delete ( void *  p) throw ()

Definition at line 125 of file memory.cpp.

void operator delete[] ( void *  p) throw ()

Definition at line 175 of file memory.cpp.

void* operator new ( size_t  size) throw (std::bad_alloc)

Definition at line 95 of file memory.cpp.

void* operator new[] ( size_t  size) throw (std::bad_alloc)

Definition at line 144 of file memory.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation