<?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 - Two interesting and difficult problems with descriptors - Comments</title>
 <link>http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors</link>
 <description>Comments for &quot;Two interesting and difficult problems with descriptors&quot;</description>
 <language>en</language>
<item>
 <title>Re: Two interesting and difficult problems with descriptors</title>
 <link>http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors#comment-40190</link>
 <description>&lt;p&gt;Yep, you&#039;re absolutely correct... but unfortunately, like I mentioned in the post, it wasn&#039;t introduced in earlier version of the SDK, and this program has to be compatible with Series 80 devices.&lt;/p&gt;

&lt;p&gt;Another &quot;gotcha&quot; I failed to mention on the above post:&lt;br /&gt;
&lt;pre class=&quot;bb-code-block&quot;&gt;
	iBuffer = HBufC8::NewL(iRequiredLength);
	iBufPtr.Set((TUint8*)iBuffer-&amp;gt;Ptr(), 0, iRequiredLength);
	iSocket-&amp;gt;Read(iBufPtr, iStatus);
&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;The problem with this is that the RSocket will adjust the TPtr8&#039;s iBufPtr&#039;s new length, but &lt;span style=&quot;font-style:italic&quot;&gt;not&lt;/span&gt; the HBufC8 iBuffer&#039;s descriptor (although the iBuffer correctly has the data). Guess this would be Problem 3 &lt;img src=&quot;/sites/all/modules/smileys/packs/example/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt;.&lt;/p&gt;

&lt;p&gt;I ended up giving up on the idea of using the HBufC8... it just wasn&#039;t worth it.  Now I have an array and only use one descriptor, the TPtr8.  The HBufC8 was actually just extra unnecessary overhead to a byte buffer.  As it turns out, I know the maximum size of any data coming from the server, so I simply have:&lt;br /&gt;
&lt;pre class=&quot;bb-code-block&quot;&gt;
	// member variable
	unsigned char iBuffer[8192];

	// In the class method...
	iBufPtr.Set(iBuffer, 0, iRequiredLength);
	iSocket.Read(iBufPtr, iStatus);
&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;This way is a little easier to read, always guarantees I won&#039;t run out of memory for the buffer, and doesn&#039;t require the overhead of an HBufC8.  (By the way, note that you could also have iBuffer as an unsigned char* pointer, and allocate the memory, and still be able to use the exact same code)&lt;/p&gt;

&lt;p&gt;-euroq&lt;/p&gt;</description>
 <pubDate>Thu, 26 Jul 2007 21:52:39 +0200</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">comment 40190 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Two interesting and difficult problems with descriptors</title>
 <link>http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors#comment-40188</link>
 <description>&lt;p&gt;Both your problems would be solved if you switched to using an RBuf - its max length doesn&#039;t get rounded up to the size of the heap cell like a HBufC and as RBuf derives from TDes you can pass it into a function taking that as a parameter.&lt;/p&gt;</description>
 <pubDate>Thu, 26 Jul 2007 19:33:19 +0200</pubDate>
 <dc:creator>Mr. Buttington F. Phucque Lewis</dc:creator>
 <guid isPermaLink="false">comment 40188 at http://www.newlc.com</guid>
</item>
<item>
 <title>Two interesting and difficult problems with descriptors</title>
 <link>http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors</link>
 <description>&lt;p&gt;Descriptors seem to be the bane of all newcomers to Symbian programming.  I thought I had them down, but just came across two problem that took me a while to solve, and might send newbies running around for days.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/en/forum/two-interesting-and-difficult-problems-descriptors#comments</comments>
 <category domain="http://www.newlc.com/en/forums/symbian-c">Symbian C++</category>
 <pubDate>Thu, 26 Jul 2007 19:14:16 +0200</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">18465 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
