Re: [Rd] Ctrl-C of functions that allocated mem

From: oliver <oliver_at_first.in-berlin.de>
Date: Thu, 09 Jun 2011 16:42:33 +0200

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.
[...]

In the printed (pdf) version of R-exts I found that R_alloc() and S_alloc() and some other functions from section 6.1.1 have return type char*.

This seesm to be a relict from the K&R era, because since ANSI C void* is the type for generic pointers.

will it be changed in the future, so that R_alloc() will be void* R_alloc() one day?

Ciao,

   Oliver



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 09 Jun 2011 - 14:47:26 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 09 Jun 2011 - 15:00:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive