🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2637

Re: Legal alloca?

#2637
From: John Winters
Date: Sun, 21 Apr 1996 17:40
25 lines
1609 bytes
In article <4lbd7t$m27@solutions.solon.com>,
John Cochran <jdc@access.digex.net> wrote:
>How about 
>
>4) It exists as a normal function that uses malloc. Every block of memory
>   allocated is placed in a linked list control structure that has a copy
>   of the stack pointer at the time of call.  Whenever alloca is called, it
>   first frees all memory blocks that have a recorded stack pointer
>   (larger or smaller depending on direction of stack growth) than the
>   current stack pointer.  This method doesn't immediately free memory
>   allocated by alloca(), but does keep the number of blocks needing to
>   be released fairly small.  This method is used by the GNU alloca()
>   function supplied with some of the GNU programs.
>

This would break fairly terminally in a program which, say, used
alloca in a single routine which was called repeatedly, each time
allocating a chunk of working memory.  The memory would never get
freed because at each call the stack pointer would be the same
as it was the previous time.

John

-- 
John Winters.  Wallingford, Oxon, England.
Technical Details
Message-ID: <4ldru4$5ub@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4koe4u$8sl@solutions.solon.com> <4l33l8$7of@solutions.solon.com> <4l880s$75k@solutions.solon.com> <4lbd7t$m27@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: John Winters <john@polo.demon.co.uk>
Newsgroups: comp.lang.c.moderated
Subject: Re: Legal alloca?
Date: 21 Apr 1996 12:40:20 -0500
Organization: Wallingford
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4ldru4$5ub@solutions.solon.com>
References: <4koe4u$8sl@solutions.solon.com> <4l33l8$7of@solutions.solon.com> <4l880s$75k@solutions.solon.com> <4lbd7t$m27@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com