#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <memory>
#include "vw_exception.h"
Go to the source code of this file.
◆ calloc_mergable_or_throw
◆ free_fn
◆ free_ptr
◆ calloc_or_throw() [1/2]
template<class T >
T* calloc_or_throw |
( |
size_t |
nmemb | ) |
|
Definition at line 9 of file memory.h.
References THROW_OR_RETURN.
14 void* data = calloc(nmemb,
sizeof(T));
17 const char* msg =
"internal error: memory allocation failed!\n";
#define THROW_OR_RETURN(...)
◆ calloc_or_throw() [2/2]
Definition at line 26 of file memory.h.
28 return *calloc_or_throw<T>(1);
◆ destroy_free()
template<class T >
void destroy_free |
( |
void * |
temp | ) |
|
◆ free_it()
void free_it |
( |
void * |
ptr | ) |
|
|
inline |
◆ scoped_calloc_or_throw()
template<class T , typename... Args>
free_ptr<T> scoped_calloc_or_throw |
( |
Args &&... |
args | ) |
|
Definition at line 44 of file memory.h.
References calloc_mergable_or_throw, and THROW.
46 T* temp = calloc_or_throw<T>(1);
47 new (temp) T(std::forward<Args>(args)...);
48 return std::unique_ptr<T, free_fn>(temp, destroy_free<T>);