<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: strstr in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582464#M25422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Thu Sep 16 06:55:52 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I understand the point of strstr() :p The question really was why are you calling it multiple times (in the for loop) with the same parameters? Surely you will get the same result each time!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, as far as I can tell, there is no issue with strstr(). If you have evidence that there is an issue, then please provide a compilable example, along the lines of the one at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.cplusplus.com/reference/clibrary/cstring/strstr/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:03:14 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:03:14Z</dc:date>
    <item>
      <title>strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582459#M25417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by renan on Thu Sep 16 04:21:14 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been having problem with strstr. It get stuck (or take too long) in a loop that tests the contents of a vector. This is part of my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (loop = 0; loop &amp;lt; ROOT_DIR_SIZE; loop++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (strstr ((const char *)buffer, (const char *)dev) != NULL)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; device = TRUE;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop++;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is a simple code, ROOT_DIR_SIZE is 512! So it isn't that big.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Renan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582459#M25417</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582460#M25418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Thu Sep 16 05:32:05 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I presume you are linking against redlib? And at what optimisation level? And what target MCU?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, I've just run a few simple tests on strstr() and can't see anything obviously wrong with it. If you pause your code after it has hung, where actually are you? And&amp;nbsp; are the values pointed to by buffer/dev actually sensible ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code does seem a little strange though - I presume that an interrupt handler/another task is updating buffer / dev ? If that is the case, it might be worth disabling interrupts around the call to strstr() to see if that changes the behaviour that you see.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582460#M25418</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582461#M25419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by renan on Thu Sep 16 05:57:58 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I presume you are linking against redlib? And at what optimisation level? And what target MCU?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using newlib (don't remember why). I will try redlib.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No optimizations. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Target MCU: LPC1768&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Your code does seem a little strange though - I presume that an interrupt handler/another task is updating buffer / dev ?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no&amp;nbsp; interrupt handler/another task updating buffer. I use memcpy to read from flash to ram. That's how my buffer is filled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will try linking againt redlib, and see if there is any difference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Renan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582461#M25419</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582462#M25420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Thu Sep 16 06:16:10 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Newlib strstr() seems to work OK too. Always helpful with C library related issues to know which library you are using though ! :)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: renan&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;There is no&amp;nbsp; interrupt handler/another task updating buffer. I use memcpy to read from flash to ram. That's how my buffer is filled.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure I follow why you have your call to strstr() inside a for loop then, as nothing is updating the buffer whilst you are in the for loop. Thus if strstr() returns NULL once, it will return NULL everytime.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there more going on in your code here than the snippet suggests ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582462#M25420</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582463#M25421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by renan on Thu Sep 16 06:37:38 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Always helpful with C library related issues to know which library you are using though ! :)&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are right! :)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, the idea is to search for a string inside the buffer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just want to see if the buffer contains (in any position), for example, the string "S9700-DEV".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I just need to know if this example string exists in the buffer. :D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582463#M25421</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582464#M25422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Thu Sep 16 06:55:52 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes I understand the point of strstr() :p The question really was why are you calling it multiple times (in the for loop) with the same parameters? Surely you will get the same result each time!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, as far as I can tell, there is no issue with strstr(). If you have evidence that there is an issue, then please provide a compilable example, along the lines of the one at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.cplusplus.com/reference/clibrary/cstring/strstr/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582464#M25422</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582465#M25423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by renan on Thu Sep 16 07:08:35 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I changed to redlib, it began to work again.... :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Whatever, if I find something I'll keep you informed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Renan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582465#M25423</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582466#M25424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Thu Sep 16 09:55:45 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I see CodeRed's point though. You are doing the an identical comparison, 256 times (you are incrementing the loop counter in for statement and in the loop body).&amp;nbsp; No wonder it is slow.!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582466#M25424</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: strstr</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582467#M25425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by renan on Thu Sep 16 10:40:54 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that...:o This code isn't good... I have to change it... :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Renan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:03:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/strstr/m-p/582467#M25425</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:03:16Z</dc:date>
    </item>
  </channel>
</rss>

