<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>it is wong use malloc?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/24876/it-is-wong-use-malloc</link><description> 
Dear Sir madams, 

 
we wish use linklist to effishiently sort data then build tree in
are controllar. 

 
In your humble oppionion,it is wong use malloc,calloc and realloc
in 8051? 

 
Can you advise? It first year in industry after study in
Beijing</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/135701?ContentTypeID=1</link><pubDate>Sat, 14 Mar 2009 00:20:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3a544c09-9de7-40fe-b9ba-11844c706c83</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
But you &lt;i&gt;&lt;b&gt;do&lt;/b&gt;&lt;/i&gt; still need to know the maximum size at
compile time - because you have to define the heap size!&lt;/p&gt;

&lt;p&gt;
So, given that you have to fix the heap size at build time anyhow,
you might just as well define the data structures &amp;quot;statically&amp;quot;.&lt;/p&gt;

&lt;p&gt;
As has already been mentioned, it is &lt;b&gt;&lt;i&gt;not&lt;/i&gt; necessary&lt;/b&gt;
to use dynamic allocation in order to use linked lists!&lt;/p&gt;

&lt;p&gt;
It is perfectly fine to define a static set of list entries, and
simply link them into an &amp;quot;in-use&amp;quot; list or a &amp;quot;free&amp;quot; list as &amp;amp; when
required at runtime.&lt;/p&gt;

&lt;p&gt;
That gives you all the convenience of linked lists with none of
the risks &amp;amp; overheads of dynamic allocation.&lt;/p&gt;

&lt;p&gt;
Of course, the 8051 is still not a great choice for a &amp;quot;data
processing&amp;quot; task like this; an ARM would probably be a better choice
- and may well be no more expensive...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/55621?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 21:32:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e4719487-f67a-4b06-abaf-8a06d247ac90</guid><dc:creator>Neil Kurzmam</dc:creator><description>&lt;p&gt;&lt;p&gt;
wrong is a strong word.&lt;br /&gt;
Will it work sure but it will be bigger and slower than other
methods.&lt;br /&gt;
You better know how much data you are getting embedded systems have
to handle errors on there own. What will yours do if it has too
much?&lt;br /&gt;
Have you chosen the correct CPU?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/55620?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 06:49:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:03a5daa2-937d-49bd-bb9e-6e048fca1721</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;we wish use linklist to effishiently sort data then build tree
in are controllar.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;In your humble oppionion,it is wong use malloc,calloc and
realloc in 8051?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
your problem is that you are trying to apply large processor
techniques/applications to a small processor.&lt;/p&gt;

&lt;p&gt;
With a large fast processor, such as a PC you can code based on
&amp;#39;programmer efficiency&amp;#39; with a small slow processor (e.g. a 12MHZ 12
clocker &amp;#39;51) you have to code for &amp;#39;processor efficiency&amp;#39;&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/125317?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 05:33:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:89400941-3992-4d3c-a406-4d74bf27c9b5</guid><dc:creator>Justin Case</dc:creator><description>&lt;p&gt;&lt;p&gt;
Malloc can be useful if you do not know the size that something
needs to be at compile time, and you have two competing needs for
memory.&lt;/p&gt;

&lt;p&gt;
If you have to free allocated memory then fragmentation becomes a
problem.&lt;/p&gt;

&lt;p&gt;
As with lots of C code care is need.&lt;/p&gt;

&lt;p&gt;
Efficiency depends on what you are trying to do.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/114767?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 05:21:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3f0a0f68-32a8-4c0a-8e91-e3f8245415fe</guid><dc:creator>John McLane</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thank you. Think i see what you say. unnowm size, unnowm memory
leek. Bad for us. dangerus for hole viallage.We speak to boss to tell
him limits.but need know which mefod is more effishient?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/101711?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 04:58:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:99fd2586-eb2d-4a2e-ab1f-cadba7aca8b4</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
using dynamically allocated memory comes with a cost - memory
fragmentation which slows memory access over time is one of them. if
a path in the program fails to release it, you are in serious
trouble. don&amp;#39;t forget that you are not working on a powerful PC.
better to allocate a large buffer statically and limit the maximum
amount of incoming data, or ignore it is it exceeds maximum allowed
size. but if you choose to use it anyway, don&amp;#39;t forget to check the
return value of the allocating function!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/77258?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 04:53:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65513d0d-2296-4c77-bd67-b79611cd16c2</guid><dc:creator>John McLane</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanking you btoh but me more comfused hear. malloc is needad
becaurse of variable input data. We never know size of input.I think
we use malloc to dynamikally alocatte space like Justin says yes? No
fixed size at factory.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/55622?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 04:46:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:063ea10f-abdf-46d1-a167-615066162820</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
but you can easily write an implementation of a linked list that
does not use dynamically allocated memory. are you sure that you are
using the right data structure? for faster operations, you can use a
hash table, for example.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: it is wong use malloc?</title><link>https://community.arm.com/thread/55628?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2009 04:45:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7a5bc166-58bd-42ae-9511-787699bae944</guid><dc:creator>Justin Case</dc:creator><description>&lt;p&gt;&lt;p&gt;
I use it all the time, just go ahead.&lt;br /&gt;
Good luck with you career.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>