Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #10909

Re: Manage an unknown number of objects without malloc

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Uno <merrilljensen@q.com>
Newsgroups comp.lang.c
Subject Re: Manage an unknown number of objects without malloc
Date Sun, 25 Sep 2011 04:52:06 -0700
Lines 21
Message-ID <9e8feaFu6kU1@mid.individual.net> (permalink)
References <j3a6gd$415$1@nnrp.ngi.it> <9f58c08f-d1a2-4d6b-ba86-3620e52aa9f2@o9g2000vbo.googlegroups.com> <0578e15c-8633-482f-832e-7d1b82e61abd@u6g2000vbo.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net +kvV7GS3IcU+Jg0f6N+XEAXYf2Bqaqhly2xL8/HU8bdVLzMots
Cancel-Lock sha1:zm3a/0xEwhOFw9tqSGwdlmkavjo=
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.22) Gecko/20110902 Thunderbird/3.1.14
In-Reply-To <0578e15c-8633-482f-832e-7d1b82e61abd@u6g2000vbo.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c:10909

Show key headers only | View raw


On 9/25/2011 1:09 AM, Malcolm McLean wrote:
> On Aug 30, 6:18 am, HENRY Eshbaugh<henryeshba...@gmail.com>  wrote:
>>
>> Write your own malloc(). Read the kmalloc() implementation in the
>> Linux kernel, plus the stuff on caching.
>>
> If there's no malloc(), there's usually a good reason for that, which
> is that resources are so constrained that the tiny memory pool will
> fragment and the function start returning nulls in no time.

If there's no malloc(), get your money back.  2 gigs is disposable now.
>
> However you can implement a stack allocator. Simply pop and push
> regions on the stack. This means that all memory you allocate has to
> be freed in strict reverse order, and only the stack top can be
> reallocated. Most small programs can be written to obey these rules.
> (The exception is when you need a tree or graph like structure).

All structures are graph-like.  Some are trivial.
-- 
Uno

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Manage an unknown number of objects without malloc Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-25 01:09 -0700
  Re: Manage an unknown number of objects without malloc Uno <merrilljensen@q.com> - 2011-09-25 04:52 -0700
    Re: Manage an unknown number of objects without malloc Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-25 04:57 -0700
      Re: Manage an unknown number of objects without malloc Uno <merrilljensen@q.com> - 2011-09-26 22:06 -0700
        Re: Manage an unknown number of objects without malloc Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-27 01:09 -0700
          Re: Manage an unknown number of objects without malloc Uno <merrilljensen@q.com> - 2011-09-27 04:17 -0700
          Re: Manage an unknown number of objects without malloc Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-27 11:54 +0100
            Re: Manage an unknown number of objects without malloc Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-09-27 04:43 -0700

csiph-web