<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - which string variable would be a better choice as regards to memory usage????? - Comments</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage</link>
 <description>Comments for &quot;which string variable would be a better choice as regards to memory usage?????&quot;</description>
 <language>en</language>
<item>
 <title>one more problem????????</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41878</link>
 <description>&lt;p&gt;What does the following lines do?&lt;br /&gt;
I have never came across any such thing before....&lt;br /&gt;
I cant get any help from sdk also&lt;/p&gt;

&lt;p&gt;import e32&lt;br /&gt;
e32.start_exe(&#039;z:\\system\\programs\\apprun.exe&#039;,&#039;z:\\system\\apps\\camcorder\\camcorder.app&#039;);&lt;/p&gt;

&lt;p&gt;What I guess--------&lt;br /&gt;
---------------------------&lt;/p&gt;

&lt;p&gt;&quot;apprun.exe &quot;  -------- is an exe file&lt;br /&gt;
&quot;camcorder.app&quot;------is an app file&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;  the startexe()&lt;br /&gt;
           starts the apprun.exe from camcorder.app&lt;/p&gt;</description>
 <pubDate>Fri, 28 Sep 2007 08:57:11 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41878 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41837</link>
 <description>&lt;p&gt;Yes, all with the same &quot;base character&quot;.&lt;/p&gt;

&lt;p&gt;The thing to think of is that this is not correct in all languages.  &lt;br /&gt;
For example, in swedish the letter &quot;å&quot; is not an &quot;a&quot; with a ring, it is a letter of its own. same with &quot;ö&quot;, in swedish, that is not an o with dots on, it is its own letter. (they even have their own keys on my keyboard)&lt;/p&gt;

&lt;p&gt;But, CompareF will treat them as the same letter when comparing.&lt;/p&gt;

&lt;p&gt;Therefore, CompareF is good for quick and dirty compare, ignoring case and such, but if you want to write a search function that should make sense in all european languages, you need to use CompareC wich is locale dependent.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 26 Sep 2007 13:29:30 +0200</pubDate>
 <dc:creator>alh</dc:creator>
 <guid isPermaLink="false">comment 41837 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string ..................</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41834</link>
 <description>&lt;p&gt;what I understood:--&lt;br /&gt;
--------------------------------&lt;/p&gt;

&lt;p&gt;  in case of folding&lt;br /&gt;
 locating &quot;e&quot; in any word will search for all characters that look like &quot;e&quot;&lt;br /&gt;
like------&lt;br /&gt;
in ur example&lt;br /&gt;
--------------------&lt;br /&gt;
 E                -- in  --HELLO&lt;br /&gt;
 e with cap-- in  --deja-vu  (sorry I could not write the way u have written)&lt;br /&gt;
 e                -- in  --french&lt;br /&gt;
 e                -- in  --english&lt;/p&gt;

&lt;p&gt;Is that right?????????&lt;/p&gt;</description>
 <pubDate>Wed, 26 Sep 2007 13:10:52 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41834 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41831</link>
 <description>&lt;p&gt;Locate() or LocateReverse() are fine to use if you are looking for characters like &#039;&lt;span style=&quot;font-weight:bold&quot;&gt;,&lt;/span&gt;&#039; as in your code above.&lt;/p&gt;

&lt;p&gt;Using of Collated/Folded version only make sense if you are dealing with character.&lt;br /&gt;
Now imagine you want to locate all &#039;&lt;span style=&quot;font-weight:bold&quot;&gt;e&lt;/span&gt;&#039; in the following sentence: &quot;HELLO, is déja-vu a french or english word ?&quot;&lt;br /&gt;
Depending on the primitive you are using you will match all (E,é,e) or only some of the e letters.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 26 Sep 2007 11:16:46 +0200</pubDate>
 <dc:creator>eric</dc:creator>
 <guid isPermaLink="false">comment 41831 at http://www.newlc.com</guid>
</item>
<item>
 <title>folding and collation</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41828</link>
 <description>&lt;p&gt;  There was another concept that I came across was &quot;folding&quot;  and &quot;collation&quot;.&lt;/p&gt;

&lt;p&gt;This was when I was planning to use &quot;locate()&quot; on &quot;TPtrC&quot;.&lt;/p&gt;

&lt;p&gt;There were 2 additional functions &quot;LocateReverseF()&quot; and &quot;LocateReverse()&quot;&lt;/p&gt;

&lt;p&gt; &quot;LocateReverseF()&quot; --------Searches for the first occurrence of a folded character within this descriptor&#039;s folded data&lt;/p&gt;

&lt;p&gt;I was confused with what folding is&lt;/p&gt;

&lt;p&gt;Then I referred to  the article---&gt;&lt;br /&gt;
 » Symbian OS v9.2 » Symbian OS guide » Base » Using User Library (E32) » Buffers and Strings » Using Descriptors » Descriptor concepts » Folding and collation (comparing strings)&lt;/p&gt;

&lt;p&gt;here I was more confused with the language and could not understand anything&lt;/p&gt;

&lt;p&gt;some of the terms that created confusion were:-&lt;/p&gt;

&lt;p&gt;  - normalising text for comparison &lt;br /&gt;
  - converting accented characters to characters without accents &lt;br /&gt;
  - tolerant comparisons&lt;br /&gt;
  - comparisons that are biased towards a match&lt;br /&gt;
  - locale-independent behaviour&lt;br /&gt;
  - no guarantee that folding is in any way culturally appropriate&lt;br /&gt;
  - should not be used for comparing strings in natural language&lt;/p&gt;

&lt;p&gt;Then I dropped idea of using &quot;LocateReverseF()&quot; &lt;/p&gt;

&lt;p&gt;and used &quot;LocateReverse()&quot;  instead.&lt;/p&gt;

&lt;p&gt;The statementb in which i used them was&lt;br /&gt;
          do{---------}&lt;br /&gt;
          while(XYZ.Locate(&#039;,&#039;)==XYZ.LocateReverse(&#039;,&#039;));&lt;/p&gt;

&lt;p&gt;But I still  wonder if using &quot;locate&quot;   for    &quot;,&#039;&quot;  was right       !!!!!!!!!&lt;br /&gt;
          &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Wed, 26 Sep 2007 10:50:27 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41828 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string ................</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41827</link>
 <description>&lt;p&gt;nice article!&lt;/p&gt;

&lt;p&gt;I understood some of the things I had confusion in  !!!!!&lt;/p&gt;

&lt;p&gt;and also came to know about some new things.........&lt;/p&gt;

&lt;p&gt;a very nice article indeed.&lt;/p&gt;

&lt;p&gt;Thanx ..........&lt;/p&gt;</description>
 <pubDate>Wed, 26 Sep 2007 10:30:36 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41827 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41804</link>
 <description>&lt;p&gt;Numpy Alert has very good points.&lt;/p&gt;

&lt;p&gt;Another thing that helps is to take the time to actually understand what the &quot;heap&quot; and the &quot;stack&quot; is, and how they are used in C++ in generall.&lt;/p&gt;

&lt;p&gt;Understanding this, and you will not have to rely on the documentation.&lt;br /&gt;
And knowing if something is on the heap or the stack and choosing when to allocate the object where, becomes very easy.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Tue, 25 Sep 2007 12:57:06 +0200</pubDate>
 <dc:creator>alh</dc:creator>
 <guid isPermaLink="false">comment 41804 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41777</link>
 <description>&lt;p&gt;When Symbian talk about something being allocated on the stack or the heap they often aren&#039;t clear or precise enough for newbies to understand what they mean.&lt;/p&gt;

&lt;p&gt;Check out item number 9 in &lt;a href=&quot;http://www.newlc.com/topic-13580&quot;&gt;http://www.newlc.com/topic-13580&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Mon, 24 Sep 2007 22:51:11 +0200</pubDate>
 <dc:creator>Numpty Alert</dc:creator>
 <guid isPermaLink="false">comment 41777 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable ............................</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41690</link>
 <description>&lt;p&gt;hi ,&lt;br /&gt;
        I used RBuf descriptors;&lt;/p&gt;

&lt;p&gt;---------------------------------------------------------------------------------------&lt;br /&gt;
I have declared RBuf descriptors in the &quot;xxx .h&quot; file as follows:-&lt;/p&gt;

&lt;p&gt;RBuf   iFormat_Resolution ;&lt;/p&gt;

&lt;p&gt;-----------------------------------------------------------------&lt;br /&gt;
In the &quot;.cpp&quot; file i have used it like this:-&lt;/p&gt;

&lt;p&gt;     TInt separator_indx=SmsBody.Locate(&#039;,&#039;);&lt;br /&gt;
     iFormat_Resolution=SmsBody.Left(separator_indx+1);&lt;/p&gt;

&lt;p&gt;----------------------------------------------------------------------------------------&lt;/p&gt;

&lt;p&gt;Do I require to free the RBuf variables after use?&lt;br /&gt;
if yes then&lt;br /&gt;
     tell me if using &quot;delete  iFormat_Resolution&quot; in the destructor of the class will do the job.&lt;br /&gt;
     &lt;/p&gt;

&lt;p&gt;     OR &lt;br /&gt;
      should I use some other approach.&lt;/p&gt;

&lt;p&gt;With Regards&lt;br /&gt;
Sandeep Mohapatra!&lt;/p&gt;</description>
 <pubDate>Mon, 24 Sep 2007 06:55:31 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41690 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41708</link>
 <description>&lt;p&gt;The class &quot;RBuf&quot; itself can live either on heap or the stack as a temporary function variable (like all correctly designed R-classes)&lt;/p&gt;

&lt;p&gt;The string it represents, always live on the heap. &lt;/p&gt;

&lt;p&gt;the RBuf class hides the allocation and reallocation of it in an easy way.&lt;/p&gt;

&lt;p&gt;You should let the class that owns the string keep the actual RBuf object, and to all other functions, you should pass it along as a const TDesC&amp; if it is to be only read, a const TDes&amp; if it is to be changed, and RBuf&amp; only if you need to reallocate it, and never, ever,  pass it &quot;by copy&quot;.&lt;/p&gt;

&lt;p&gt;ownership means the one that is responsible for the strings deallocation in case of error or exit, every object you allocate must have exactly one &quot;owner&quot; that is responsible for the objects destruction.&lt;br /&gt;
This is an extremly important concept in symbian, and you should make sure you understand it properly.&lt;br /&gt;
&lt;/p&gt;</description>
 <pubDate>Fri, 21 Sep 2007 15:44:31 +0200</pubDate>
 <dc:creator>alh</dc:creator>
 <guid isPermaLink="false">comment 41708 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable ........</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41699</link>
 <description>&lt;p&gt;&lt;br /&gt;
I am quite confused.&lt;/p&gt;

&lt;p&gt;-&gt; I went through the class documentation of RBuf in SDK. It says the HBuf is heap-based. Then I went through another article in the SDK &lt;/p&gt;

&lt;p&gt;» Symbian OS v9.2 » Symbian OS guide » Base » Using User Library (E32) » Buffers and Strings » Using Descriptors » How to Use Descriptors » How to use the resizable buffer descriptor RBuf&lt;/p&gt;

&lt;p&gt;It says that there is no guarantee that RBuf is created on the heap.It can be on the stack also.&lt;br /&gt;
So, I want to know &quot;in what condition is it on the stack&quot;???????????&lt;/p&gt;

&lt;p&gt;-&gt;also there are three ways to create RBuf from existing buffers:-&lt;br /&gt;
     A. RBuf.CreateL();---------------------------------//this does not take ownership&lt;br /&gt;
     B. RBuf.Assign();-----------------------------------//this takes ownership&lt;br /&gt;
     C.through Assignment operator----------------//no documentation on how to use&lt;/p&gt;

&lt;p&gt;-&gt;What is the difference between ownership and non-ownership?????????&lt;br /&gt;
-&gt;Which of the above methods is appropriate for which case????????????&lt;/p&gt;

&lt;p&gt;-&gt;There is an approach of using RBuf.ReallocL(0) before using RBuf.close()&lt;br /&gt;
    Is it necessary to change size of RBuf to zero using ReAllocL()  before using RBuf.close????????????&lt;/p&gt;

&lt;p&gt; &lt;br /&gt;
&lt;/p&gt;</description>
 <pubDate>Fri, 21 Sep 2007 11:49:37 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">comment 41699 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41693</link>
 <description>&lt;p&gt;RBuf is an R-class, and follow the same rules as all R-classes.&lt;/p&gt;

&lt;p&gt;That is, to free its resources, you have to call Close() on it.&lt;/p&gt;

&lt;p&gt;And if you use a temporary one in a function that might leave, you have to call CleanupClosePushL() on it after creating it, so incase of a leave, it will be closed properly.&lt;br /&gt;
&lt;/p&gt;</description>
 <pubDate>Fri, 21 Sep 2007 10:21:46 +0200</pubDate>
 <dc:creator>alh</dc:creator>
 <guid isPermaLink="false">comment 41693 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: which string variable would be a better choice as regards to</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41672</link>
 <description>&lt;p&gt;I&#039;d like to make you aware of also the nice class RBuf.&lt;/p&gt;

&lt;p&gt;It is a new class, encapsulating a lot of the &quot;mess&quot; using normal descriptors, and is often very convenient to use, specially when you have a dynamic amount of dynamic length strings.&lt;/p&gt;

&lt;p&gt;Generally, you should avoid putting any strings on the stack in symbian because of limited stack space.&lt;/p&gt;

&lt;p&gt;TBuf&lt;&gt; doesn&#039;t necessarily mean it is on stack though, if you for example use it as a member variable in a CBase class, it will (ofcourse) end up on the heap when you create your CBase object on the heap. &lt;/p&gt;

&lt;p&gt;TPtrC and TPtr doesn&#039;t represent any memory, it is just pointers to memory allocated elsewhere (another descriptor, or just a block of memory, either on stack or on heap)&lt;/p&gt;

&lt;p&gt;Using TBuf&lt;&gt; will mean you pre-allocate memory, and if your strings are shorter, you will waste the remaining space.&lt;/p&gt;

&lt;p&gt;With RBuf you can easily create and realloc exactly as much memory as you need for the string.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;</description>
 <pubDate>Thu, 20 Sep 2007 15:59:15 +0200</pubDate>
 <dc:creator>alh</dc:creator>
 <guid isPermaLink="false">comment 41672 at http://www.newlc.com</guid>
</item>
<item>
 <title>Good choice for memory usage</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comment-41662</link>
 <description>&lt;p&gt;It depends on how many variables you have. If you need only one string, or a few of them, more or less it doesn&#039;t matter and you can take whatever you like.&lt;/p&gt;

&lt;p&gt;If you need hundreds or even thousands of buffers, the story changes completely.&lt;/p&gt;

&lt;p&gt;How many do you need, then?&lt;br /&gt;
&lt;/p&gt;</description>
 <pubDate>Thu, 20 Sep 2007 14:02:34 +0200</pubDate>
 <dc:creator>rbrunner</dc:creator>
 <guid isPermaLink="false">comment 41662 at http://www.newlc.com</guid>
</item>
<item>
 <title>which string variable would be a better choice as regards to memory usage?????</title>
 <link>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage</link>
 <description>&lt;p&gt;Hi friends,&lt;br /&gt;
        I need to know which variable type (HBufC,TBuf Cor TPtrC) would be better to use under&lt;br /&gt;
normal circumstances.&lt;br /&gt;
            HBufC, TPtrC-&gt; represent heap memory&lt;br /&gt;
            TBufC-&gt; probably represents memory on stack&lt;/p&gt;

&lt;p&gt;   Also, &lt;br /&gt;
    -&gt;   I have the constraint that the size of data that I will be receiving is also unknown.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/en/forum/which-string-variable-would-be-better-choice-regards-memory-usage#comments</comments>
 <category domain="http://www.newlc.com/en/forums/symbian-c">Symbian C++</category>
 <pubDate>Thu, 20 Sep 2007 13:31:37 +0200</pubDate>
 <dc:creator>sandeepmhptr</dc:creator>
 <guid isPermaLink="false">19028 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
