From oliver at first.in-berlin.de  Thu Jun  9 13:32:52 2011
From: oliver at first.in-berlin.de (oliver)
Date: Thu, 9 Jun 2011 13:32:52 +0200
Subject: [Rd] Ctrl-C of functions that allocated mem
In-Reply-To: <FF0548F3-A51E-426E-8D18-367E34FD61E2@r-project.org>
References: <20110609000627.GA3482@siouxsie>
	<FF0548F3-A51E-426E-8D18-367E34FD61E2@r-project.org>
Message-ID: <20110609113252.GB3855@siouxsie>

On Wed, Jun 08, 2011 at 08:40:21PM -0400, Simon Urbanek wrote:
> 
> On Jun 8, 2011, at 8:06 PM, oliver wrote:
> 
> > 
> > Hello,
> > 
> > 
> > what happens, when a function (R-extension in C), that allocated memory
> > (strdup(), malloc()/calloc() and so on), and is used in interactive mode, then
> > will be stopped via Ctrl-C?
> > 
> > I would assume that there remains allocated memory,
> > which is not usable and also not accessable (hence no
> > way to free it).
> > 
> > Are there any mechanisms in R that could help in rolling
> > back the allocation?
> > 
> 
> Yes, if you read R-exts:
> http://r.research.att.com/man/R-exts.html#Memory-allocation
> you would know that you're not supposed to use malloc/calloc at all and if you allow interruption ("regular" C code does not) R_alloc does what you asked about.

OK.

There are some pages I didn't read so far.

I'm just too unpatient....
...maybe should go on reading ;)

Thanks for the hint to the R-exts.html.

.... I hope there I also will find a solution for my
filename-problem: want a char* on a filename, must use
const char* (strdup() would match that issue), and
I should not use my own allocation mechanisms.
Then there must be something to address this.

Ciao,
   Oliver



[Rd] Ctrl-C of functions that allocated mem
oliver