LIBINT
2.9.0
include
libint2
util
include/libint2/util/memory.h
1
/*
2
* Copyright (C) 2004-2024 Edward F. Valeev
3
*
4
* This file is part of Libint library.
5
*
6
* Libint library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Libint library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with Libint library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
#ifndef _libint2_src_lib_libint_libint2memory_h_
22
#define _libint2_src_lib_libint_libint2memory_h_
23
24
#include <libint2/util/generated/libint2_params.h>
25
26
#include <cstdlib>
27
28
#ifdef _MSC_VER
29
#define posix_memalign(p, a, s) \
30
(((*(p)) = _aligned_malloc((s), (a))), *(p) ? 0 : errno)
31
#endif
32
33
namespace
libint2
{
34
36
40
inline
void
*
malloc
(
size_t
nbytes) {
41
void
* result;
42
#if (LIBINT2_ALIGN_SIZE == 0)
43
result =
::malloc
(nbytes);
44
#elif defined(HAVE_POSIX_MEMALIGN)
45
posix_memalign(&result, LIBINT2_ALIGN_SIZE *
sizeof
(LIBINT2_REALTYPE),
46
nbytes);
47
#else
48
#error "LIBINT2_ALIGN_SIZE!=0 but posix_memalign is not available"
49
#endif
50
return
result;
51
}
52
54
template
<
typename
T>
55
inline
T*
malloc
(
size_t
n) {
56
return
reinterpret_cast<
T*
>
(
malloc
(n *
sizeof
(T)));
57
}
58
59
}
// namespace libint2
60
61
#endif
/* _libint2_src_lib_libint_libint2memory_h_ */
libint2
Defaults definitions for various parameters assumed by Libint.
Definition
algebra.cc:24
libint2::malloc
void * malloc(size_t nbytes)
Aligned version of malloc().
Definition
include/libint2/util/memory.h:40
Generated by
1.10.0