Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > acb94a8b2a4b1c8c2a966ed9ee99ffe4 > files > 240

lib64wcs-devel-4.18-2.mga4.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>WCSLIB 4.18: Memory management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">WCSLIB 4.18
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="index.html">WCSLIB 4.18 and PGSBOX 4.18</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Memory management </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The initialization routines for certain of the WCSLIB data structures allocate memory for some of their members:</p>
<ul>
<li><a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> optionally allocates memory for the <em>crpix</em>, <em>pc</em>, <em>cdelt</em>, <em>crval</em>, <em>cunit</em>, <em>ctype</em>, <em>pv</em>, <em>ps</em>, <em>cd</em>, <em>crota</em>, <em>colax</em>, <em>cname</em>, <em>crder</em>, and <em>csyer</em> arrays in the wcsprm struct (using <a class="el" href="lin_8h.html#a7ddea28768d99f01c6be1c71a4d8fe58" title="Default constructor for the linprm struct. ">linini()</a> for certain of these). Note that <a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> does not allocate memory for the <em>tab</em> array - refer to the usage notes for <a class="el" href="wcshdr_8h.html#a6dd857f7b61a5b349cc8af5a4b6d8a1c" title="Tabular construction routine. ">wcstab()</a> in <a class="el" href="wcshdr_8h.html">wcshdr.h</a>. If the <em>pc</em> matrix is not unity, <a class="el" href="wcs_8h.html#ae5cc3f5d249755583403cdf54d2ebb91" title="Setup routine for the wcsprm struct. ">wcsset()</a> (via <a class="el" href="lin_8h.html#a5c01c0991c8d0c4437581a7c1453b09a" title="Setup routine for the linprm struct. ">linset()</a>) also allocates memory for the <em>piximg</em> and <em>imgpix</em> arrays.</li>
<li><a class="el" href="lin_8h.html#a7ddea28768d99f01c6be1c71a4d8fe58" title="Default constructor for the linprm struct. ">linini()</a>: optionally allocates memory for the <em>crpix</em>, <em>pc</em>, and <em>cdelt</em> arrays in the linprm struct. If the <em>pc</em> matrix is not unity, <a class="el" href="lin_8h.html#a5c01c0991c8d0c4437581a7c1453b09a" title="Setup routine for the linprm struct. ">linset()</a> also allocates memory for the <em>piximg</em> and <em>imgpix</em> arrays. Typically these would be used by <a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> and <a class="el" href="wcs_8h.html#ae5cc3f5d249755583403cdf54d2ebb91" title="Setup routine for the wcsprm struct. ">wcsset()</a>.</li>
<li><a class="el" href="tab_8h.html#abb7920acdfb83179d3bac65035144c02" title="Default constructor for the tabprm struct. ">tabini()</a>: optionally allocates memory for the <em>K</em>, <em>map</em>, <em>crval</em>, <em>index</em>, and <em>coord</em> arrays (including the arrays referenced by <em>index</em>[]) in the tabprm struct. <a class="el" href="tab_8h.html#ae403ff0b740916989c7386728df001c8" title="Acquire tabular memory. ">tabmem()</a> takes control of any of these arrays that may have been allocated by the user, specifically in that <a class="el" href="tab_8h.html#a0f3501cc592c78e0f2cb9922466589f2" title="Destructor for the tabprm struct. ">tabfree()</a> will then free it. <a class="el" href="tab_8h.html#a519e8e4503f7c41c0f99e8597171c97f" title="Setup routine for the tabprm struct. ">tabset()</a> also allocates memory for the <em>sense</em>, <em>p0</em>, <em>delta</em> and <em>extrema</em> arrays.</li>
</ul>
<p>The caller may load data into these arrays but must not modify the struct members (i.e. the pointers) themselves or else memory leaks will result.</p>
<p><a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> maintains a record of memory it has allocated and this is used by <a class="el" href="wcs_8h.html#a4ab38bc642c4656f62c43acf84a849f1" title="Destructor for the wcsprm struct. ">wcsfree()</a> which <a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> uses to free any memory that it may have allocated on a previous invokation. Thus it is not necessary for the caller to invoke <a class="el" href="wcs_8h.html#a4ab38bc642c4656f62c43acf84a849f1" title="Destructor for the wcsprm struct. ">wcsfree()</a> separately if <a class="el" href="wcs_8h.html#a2afc8255fde0965dddaa374463666d45" title="Default constructor for the wcsprm struct. ">wcsini()</a> is invoked repeatedly on the same wcsprm struct. Likewise, <a class="el" href="wcs_8h.html#ae5cc3f5d249755583403cdf54d2ebb91" title="Setup routine for the wcsprm struct. ">wcsset()</a> deallocates memory that it may have allocated on a previous invokation. The same comments apply to <a class="el" href="lin_8h.html#a7ddea28768d99f01c6be1c71a4d8fe58" title="Default constructor for the linprm struct. ">linini()</a>, <a class="el" href="lin_8h.html#aef9ead7c6ea6ab08f3ba3fc6a1c30303" title="Destructor for the linprm struct. ">linfree()</a>, and <a class="el" href="lin_8h.html#a5c01c0991c8d0c4437581a7c1453b09a" title="Setup routine for the linprm struct. ">linset()</a> and to <a class="el" href="tab_8h.html#abb7920acdfb83179d3bac65035144c02" title="Default constructor for the tabprm struct. ">tabini()</a>, <a class="el" href="tab_8h.html#a0f3501cc592c78e0f2cb9922466589f2" title="Destructor for the tabprm struct. ">tabfree()</a>, and <a class="el" href="tab_8h.html#a519e8e4503f7c41c0f99e8597171c97f" title="Setup routine for the tabprm struct. ">tabset()</a>.</p>
<p>A memory leak will result if a wcsprm, linprm or tabprm struct goes out of scope before the memory has been <em>free'd</em>, either by the relevant routine, <a class="el" href="wcs_8h.html#a4ab38bc642c4656f62c43acf84a849f1" title="Destructor for the wcsprm struct. ">wcsfree()</a>, <a class="el" href="lin_8h.html#aef9ead7c6ea6ab08f3ba3fc6a1c30303" title="Destructor for the linprm struct. ">linfree()</a> or <a class="el" href="tab_8h.html#a0f3501cc592c78e0f2cb9922466589f2" title="Destructor for the tabprm struct. ">tabfree()</a>, or otherwise. Likewise, if one of these structs itself has been <em>malloc'd</em> and the allocated memory is not <em>free'd</em> when the memory for the struct is <em>free'd</em>. A leak may also arise if the caller interferes with the array pointers in the "private" part of these structs.</p>
<p>Beware of making a shallow copy of a wcsprm, linprm or tabprm struct by assignment; any changes made to allocated memory in one would be reflected in the other, and if the memory allocated for one was <em>free'd</em> the other would reference unallocated memory. Use the relevant routine instead to make a deep copy: <a class="el" href="wcs_8h.html#a864c99fef9f3eee29085ce42d0ee0d64" title="Subimage extraction routine for the wcsprm struct. ">wcssub()</a>, <a class="el" href="lin_8h.html#ab8fc0ef6b34eb3327b13a00de78232b1" title="Copy routine for the linprm struct. ">lincpy()</a> or <a class="el" href="tab_8h.html#a87b3a2a84bab396a528af8382ce9ad04" title="Copy routine for the tabprm struct. ">tabcpy()</a>. </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Jul 13 2013 20:00:27 for WCSLIB 4.18 by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
</small></address>
</body>
</html>