casacore
Loading...
Searching...
No Matches
AlignMemory.h
Go to the documentation of this file.
1// # AlignMemory.h: Class to specify and calculate memory alignment
2// # Copyright (C) 2014
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_ALIGNMEMORY_H
27#define CASA_ALIGNMEMORY_H
28
29#include <casacore/casa/aips.h>
30#include <stddef.h>
31
32namespace casacore { // #Begin casa namespace
33
35 public:
36 // Default alignment is none.
38
39 // Get the alignment.
40 uInt alignment() const { return itsAlign; }
41
42 // Allocate the given amount of memory with the correct alignment.
43 // If alignment < sizeof(void*), malloc will be used, otherwise posix_memalign.
44 // The alignment must be a power of 2 for posix_memalign to succeed.
45 // It can be freed with the normal free.
46 void* alloc(size_t size) const;
47
48 private:
50};
51
52} // namespace casacore
53
54#endif
AlignMemory(uInt alignment=0)
Default alignment is none.
Definition AlignMemory.h:37
uInt alignment() const
Get the alignment.
Definition AlignMemory.h:40
void * alloc(size_t size) const
Allocate the given amount of memory with the correct alignment.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
size_t size() const
Definition Block.h:566