This file is indexed.

/usr/share/doc/libcnf-dev/html/node33.html is in libcnf-dev 4.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Allocating
Exportable Dynamic Memory</TITLE>
<META NAME="description" CONTENT="Allocating
Exportable Dynamic Memory">
<META NAME="keywords" CONTENT="sun209">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="sun209.css">
<LINK REL="next" HREF="node34.html">
<LINK REL="previous" HREF="node32.html">
<LINK REL="up" HREF="node31.html">
<LINK REL="next" HREF="node34.html">
</HEAD>
<BODY >
<BR> <HR>
<A NAME="tex2html547"
 HREF="node34.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
<A NAME="tex2html545"
 HREF="node31.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
<A NAME="tex2html539"
 HREF="node32.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>   <A HREF="sun209.html#stardoccontents"><IMG
 ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
 ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html548"
 HREF="node34.html">Accessing Dynamic Memory from C and FORTRAN</A>
<BR>
<B>Up:</B> <A NAME="tex2html546"
 HREF="node31.html">Pointers</A>
<BR>
<B> Previous:</B> <A NAME="tex2html540"
 HREF="node32.html">Pointer Registration and Conversion</A>
<BR> <HR> <P>

<!--End of Navigation Panel-->

<H2><A NAME="SECTION00082000000000000000"></A><A NAME="xref_allocating_exportable_dynamic_memory"></A>
<BR>
Allocating
Exportable Dynamic Memory
</H2>

<P>
The CNF functions 
<A HREF="node183.html#cnfMalloc"><TT>cnfMalloc</TT></A>
and
<A HREF="node155.html#cnfCalloc"><TT>cnfCalloc</TT></A>
should be used whenever you wish to dynamically allocate memory in a C
function and export the resulting pointer for use from FORTRAN. You
might also want to use them if you are writing a subroutine library
that returns pointers to dynamic memory through its public interface,
since the caller might then decide to pass these pointers on to a
FORTRAN routine.

<P>
For example, here is how you should allocate space for an array of
<TT>N</TT> FORTRAN <TT>REAL</TT> values in a C function and pass back
the resulting pointer to FORTRAN:

<P>
<FONT SIZE="-1"><BLOCKQUOTE> </FONT><PRE>
F77_POINTER_FUNCTION(ralloc)( INTEGER(N) )
{
   GENPTR_INTEGER(N)

/* Allocate the memory and return the converted pointer. */
   return cnfFptr(cnfMalloc(*N*sizeof(F77_REAL_TYPE)));
}
</PRE><FONT SIZE="-1"> </BLOCKQUOTE></FONT>

<P>
When the allocated memory is no longer required, it should be freed
using 
<A HREF="node171.html#cnfFree"><TT>cnfFree</TT></A>. 
This is how you might import the FORTRAN
pointer value allocated above back into C in order to free it:

<P>
<FONT SIZE="-1"><BLOCKQUOTE> </FONT><PRE>
F77_SUBROUTINE(rfree)( POINTER(FPNTR) )
{
   GENPTR_POINTER(FPNTR)

/* Convert back to a C pointer and then free it. */
   cnfFree(cnfCptr(*FPNTR));
}
</PRE><FONT SIZE="-1"> </BLOCKQUOTE></FONT>

<P>
Externally, these CNF memory allocation functions behave exactly like
their standard C equivalents <TT>malloc</TT>, <TT>calloc</TT> and
<TT>free</TT>. Internally, however, they perform two important
additional functions:

<UL><LI>They maintain the internal table of ``registered'' pointers, so
that the conversion functions 
<A HREF="node170.html#cnfFptr"><TT>cnfFptr</TT></A>
and
<A HREF="node157.html#cnfCptr"><TT>cnfCptr</TT></A>
can operate (if you use <TT>malloc</TT> to obtain a
pointer, for instance, then these conversion functions will fail and
return zero).

<P>

<LI>They ensure that all memory allocation results in pointers whose
lowest 32 bits (or the length of a FORTRAN <TT>INTEGER</TT>) are
unique, so that conversion between FORTRAN and C pointer values is a
well-defined operation.

</UL>

<P>
For convenience,
<A HREF="node171.html#cnfFree"><TT>cnfFree</TT></A>
is also able to free pointers
which have not been registered, in which case it behaves exactly like
<TT>free</TT>.

<P>
<BR> <HR>
<A NAME="tex2html547"
 HREF="node34.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
<A NAME="tex2html545"
 HREF="node31.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
<A NAME="tex2html539"
 HREF="node32.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>   <A HREF="sun209.html#stardoccontents"><IMG
 ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
 ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html548"
 HREF="node34.html">Accessing Dynamic Memory from C and FORTRAN</A>
<BR>
<B>Up:</B> <A NAME="tex2html546"
 HREF="node31.html">Pointers</A>
<BR>
<B> Previous:</B> <A NAME="tex2html540"
 HREF="node32.html">Pointer Registration and Conversion</A>
<BR> <HR> <P>

<!--End of Navigation Panel-->
<ADDRESS>
<I>CNF and F77 Mixed Language Programming -- FORTRAN and C<BR>Starlink User Note 209<BR>P.M. Allan<BR>A.J. Chipperfield<BR>R.F. Warren-Smith<BR>19 January 2000<BR>E-mail:<A HREF="mailto:ussc@star.rl.ac.uk">ussc@star.rl.ac.uk</A></I>
</ADDRESS>
</BODY>
</HTML>