GNU Radio 3.4.2 C++ API
gc_aligned_alloc.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2008 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00020  */
00021 #ifndef INCLUDED_GC_ALIGNED_ALLOC_H
00022 #define INCLUDED_GC_ALIGNED_ALLOC_H
00023 
00024 #include <boost/shared_ptr.hpp>
00025 
00026 /*!
00027  * \brief Return pointer to chunk of storage of size size bytes.
00028  * The allocation will be aligned to an \p alignment boundary.
00029  *
00030  * \param size is the number of bytes to allocate
00031  * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
00032  *
00033  * Throws if can't allocate memory.  The storage should be freed
00034  * with "free" when done.  The memory is initialized to zero.
00035  */
00036 void *
00037 gc_aligned_alloc(size_t size, size_t alignment = 128);
00038 
00039 /*!
00040  * \brief Return boost::shared_ptr to chunk of storage of size size bytes.
00041  * The allocation will be aligned to an \p alignment boundary.
00042  *
00043  * \param size is the number of bytes to allocate
00044  * \param alignment is the minimum storage alignment in bytes; must be a power of 2.
00045  *
00046  * Throws if can't allocate memory.  The storage should be freed
00047  * with "free" when done.  The memory is initialized to zero.
00048  */
00049 boost::shared_ptr<void>
00050 gc_aligned_alloc_sptr(size_t size, size_t alignment = 128);
00051 
00052 #endif /* INCLUDED_GC_ALIGNED_ALLOC_H */