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


Groups > comp.lang.c > #65973

Re: Allocating memory styles

From Noob <root@127.0.0.1>
Newsgroups comp.lang.c
Subject Re: Allocating memory styles
Date 2015-07-20 14:53 +0200
Organization A noiseless patient Spider
Message-ID <moiqt2$5i5$1@dont-email.me> (permalink)
References <0591b244-c066-4714-afad-3ba8db4a8676@googlegroups.com>

Show all headers | View raw


On 20/07/2015 14:36, janus wrote:

> I am going through a book and I stumbled on this class of memory allocation:
> 
> void* p = calloc(1, class->size);
> 
> *(const struct Class**) P = class;

http://www.catb.org/esr/faqs/smart-questions.html

You should provide a program that compiles, even for trivial code.
People trying to help you shouldn't have to guess about the parts
you left out. (In this case, the definition of "struct Class", and
the initialization of "class".)

The intent may have been to write something along these lines:

  struct Class *foo = malloc(sizeof *foo);
  *foo = class;

Regards.

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


Thread

Allocating memory styles janus <emekamicro@gmail.com> - 2015-07-20 05:36 -0700
  Re: Allocating memory styles Noob <root@127.0.0.1> - 2015-07-20 14:53 +0200
    Re: Allocating memory styles janus <emekamicro@gmail.com> - 2015-07-20 07:23 -0700
      Re: Allocating memory styles Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-20 16:40 +0100
        Re: Allocating memory styles janus <emekamicro@gmail.com> - 2015-07-20 12:19 -0700
  Re: Allocating memory styles Richard Heathfield <rjh@cpax.org.uk> - 2015-07-20 14:07 +0100
  Re: Allocating memory styles Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-20 14:18 +0100
  Re: Allocating memory styles jt@toerring.de (Jens Thoms Toerring) - 2015-07-20 13:47 +0000
    Re: Allocating memory styles Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-07-20 15:21 +0100
  Re: Allocating memory styles Johann Klammer <klammerj@NOSPAM.a1.net> - 2015-07-20 16:27 +0200
  Re: Allocating memory styles luser droog <luser.droog@gmail.com> - 2015-07-20 12:34 -0700
    Re: Allocating memory styles Keith Thompson <kst-u@mib.org> - 2015-07-20 14:00 -0700
      Re: Allocating memory styles luser droog <luser.droog@gmail.com> - 2015-07-20 20:29 -0700
        Re: Allocating memory styles raltbos@xs4all.nl (Richard Bos) - 2015-07-22 15:21 +0000
    Re: Allocating memory styles janus <emekamicro@gmail.com> - 2015-07-20 14:13 -0700
  Re: Allocating memory styles "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-20 14:54 -0700
    Re: Allocating memory styles "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-20 14:57 -0700

csiph-web