Current File : //usr/share/gtk-doc/html/harfbuzz/object-model-lifecycle.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Object lifecycle management: HarfBuzz Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="HarfBuzz Manual">
<link rel="up" href="object-model.html" title="The HarfBuzz object model">
<link rel="prev" href="object-model-object-types.html" title="Objects in HarfBuzz">
<link rel="next" href="object-model-user-data.html" title="User data">
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="object-model.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="object-model-object-types.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="object-model-user-data.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="object-model-lifecycle"></a>Object lifecycle management</h2></div></div></div>
<p>
Each object type in HarfBuzz provides a
<code class="function">create()</code> method. Some object types provide
additional variants of <code class="function">create()</code> to handle
special cases or to speed up common tasks; those variants are
documented in the API reference. For example,
<code class="function">hb_blob_create_from_file()</code> constructs a new
blob directly from the contents of a file.
</p>
<p>
All objects are created with an initial reference count of
<code class="literal">1</code>. Client programs can increase the reference
count on an object by calling its
<code class="function">reference()</code> method. Whenever a client
program is finished with an object, it should call its
corresponding <code class="function">destroy()</code> method. The destroy
method will decrease the reference count on the object and,
whenever the reference count reaches zero, it will also destroy
the object and free all of the associated memory.
</p>
<p>
All of HarfBuzz's object-lifecycle-management APIs are
thread-safe (unless you compiled HarfBuzz from source with the
<code class="literal">HB_NO_MT</code> configuration flag), even when the
object as a whole is not thread-safe.
It is also permissible to <code class="function">reference()</code> or to
<code class="function">destroy()</code> the <code class="literal">NULL</code>
value.
</p>
<p>
Some objects are thread-safe after they have been constructed
and set up. The general pattern is to
<code class="function">create()</code> the object, make a few
<code class="function">set_*()</code> calls to set up the
object, and then use it without further modification.
</p>
<p>
To ensure that such an object is not modified, client programs
can explicitly mark an object as immutable. HarfBuzz provides
<code class="function">make_immutable()</code> methods to mark an object
as immutable and <code class="function">is_immutable()</code> methods to
test whether or not an object is immutable. Attempts to use
setter functions on immutable objects will fail silently; see the API
Reference manual for specifics.
</p>
<p>
Note also that there are no "make mutable" methods. If client
programs need to alter an object previously marked as immutable,
they will need to make a duplicate of the original.
</p>
<p>
Finally, object constructors (and, indeed, as much of the
shaping API as possible) will never return
<code class="literal">NULL</code>. Instead, if there is an allocation
error, each constructor will return an “empty” object
singleton.
</p>
<p>
These empty-object singletons are inert and safe (although
typically useless) to pass around. This design choice avoids
having to check for <code class="literal">NULL</code> pointers all
throughout the code.
</p>
<p>
In addition, this “empty” object singleton can also be accessed
using the <code class="function">get_empty()</code> method of the object
type in question.
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.32</div>
</body>
</html>
Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat