3
<title>Block allocation - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Blocks.html#Blocks" title="Blocks">
9
<link rel="next" href="Reading-and-writing-blocks.html#Reading-and-writing-blocks" title="Reading and writing blocks">
10
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
14
Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.2 or
16
any later version published by the Free Software Foundation; with the
17
Invariant Sections being ``GNU General Public License'' and ``Free Software
18
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
19
and with the Back-Cover Text being (a) (see below). A copy of the
20
license is included in the section entitled ``GNU Free Documentation
23
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
24
GNU Manual, like GNU software.''-->
25
<meta http-equiv="Content-Style-Type" content="text/css">
26
<style type="text/css"><!--
27
pre.display { font-family:inherit }
28
pre.format { font-family:inherit }
29
pre.smalldisplay { font-family:inherit; font-size:smaller }
30
pre.smallformat { font-family:inherit; font-size:smaller }
31
pre.smallexample { font-size:smaller }
32
pre.smalllisp { font-size:smaller }
33
span.sc { font-variant:small-caps }
34
span.roman { font-family:serif; font-weight:normal; }
35
span.sansserif { font-family:sans-serif; font-weight:normal; }
41
<a name="Block-allocation"></a>
42
Next: <a rel="next" accesskey="n" href="Reading-and-writing-blocks.html#Reading-and-writing-blocks">Reading and writing blocks</a>,
43
Up: <a rel="up" accesskey="u" href="Blocks.html#Blocks">Blocks</a>
47
<h4 class="subsection">8.2.1 Block allocation</h4>
49
<p>The functions for allocating memory to a block follow the style of
50
<code>malloc</code> and <code>free</code>. In addition they also perform their own
51
error checking. If there is insufficient memory available to allocate a
52
block then the functions call the GSL error handler (with an error
53
number of <code>GSL_ENOMEM</code>) in addition to returning a null
54
pointer. Thus if you use the library error handler to abort your program
55
then it isn't necessary to check every <code>alloc</code>.
58
— Function: gsl_block * <b>gsl_block_alloc</b> (<var>size_t n</var>)<var><a name="index-gsl_005fblock_005falloc-816"></a></var><br>
59
<blockquote><p>This function allocates memory for a block of <var>n</var> double-precision
60
elements, returning a pointer to the block struct. The block is not
61
initialized and so the values of its elements are undefined. Use the
62
function <code>gsl_block_calloc</code> if you want to ensure that all the
63
elements are initialized to zero.
65
<p>A null pointer is returned if insufficient memory is available to create
67
</p></blockquote></div>
70
— Function: gsl_block * <b>gsl_block_calloc</b> (<var>size_t n</var>)<var><a name="index-gsl_005fblock_005fcalloc-817"></a></var><br>
71
<blockquote><p>This function allocates memory for a block and initializes all the
72
elements of the block to zero.
73
</p></blockquote></div>
76
— Function: void <b>gsl_block_free</b> (<var>gsl_block * b</var>)<var><a name="index-gsl_005fblock_005ffree-818"></a></var><br>
77
<blockquote><p>This function frees the memory used by a block <var>b</var> previously
78
allocated with <code>gsl_block_alloc</code> or <code>gsl_block_calloc</code>.
79
</p></blockquote></div>