Symbian3/PDK/Source/GUID-88E610C1-6662-5A12-B950-B695A7EB776C.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Fri, 22 Jan 2010 18:26:19 +0000
changeset 1 25a17d01db0c
child 3 46218c8b8afa
permissions -rw-r--r--
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-88E610C1-6662-5A12-B950-B695A7EB776C"><title>How to cleanup streams</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The Store framework makes extensive use of the cleanup stack. </p> <p>Before read streams or write streams are disposed of, for example, when an <codeph>RStoreWriteStream</codeph> or <codeph>RStoreReadStream</codeph> object goes out of scope, resources acquired by the stream objects must be released.</p> <p>The easiest way to do this is to use the <codeph>CreateLC()</codeph>, <codeph>OpenLC()</codeph>, <codeph>AppendLC()</codeph> and <codeph>ReplaceLC()</codeph> variants that put a cleanup item onto the cleanup stack.</p> <p>Before disposing of the read or write stream object, but after any data is committed, call <codeph>CleanupStack::PopAndDestroy()</codeph>. For example:</p> <codeblock id="GUID-A2C41FDD-5A52-5A7B-8965-CCFFA458D244" xml:space="preserve">...
TStreamId id = outstream.CreateLC(*store);
...
outstream.CommitL();
...
CleanupStack::PopAndDestroy();
...</codeblock> <p>For write streams, data must be committed to the stream before releasing resources.</p> <p>Alternatively, if the <codeph>CreateL()</codeph>, <codeph>OpenL()</codeph>, <codeph>AppendL()</codeph> and <codeph>ReplaceL()</codeph> variants are used, then an explicit call to <codeph>PushL()</codeph> must be made to put a cleanup item onto the cleanup stack. For example:</p> <codeblock id="GUID-DF572C67-C2F8-52F5-A8DB-3A23DC6F1A50" xml:space="preserve">...
TStreamId id = outstream.CreateL(*store);
outstream.PushL();
...
outstream.CommitL();
...
CleanupStack::PopAndDestroy();
...</codeblock> </conbody></concept>