Re: C or C++ for FOSS/linux?



"Chris F.A. Johnson" <cfajohnson@xxxxxxxxx> writes:

On 2006-12-29, Sebastian 'lunar' Wiesner wrote:
Jan Panteltje <pNaonStpealmtje@xxxxxxxxx> typed

[snip]

int *i = (int *) malloc (100*sizeof(int));

I don't know much of C programming, but that is known to me as the way
you allocate an array of 100 integers on the heap in C.

Wrong; it's:

int *i = malloc (100*sizeof(int));

You should not cast the value returned by malloc; that can mask
errors.

I have heard this before : but what errors can it mask?

If its non null you have the memory ...
.



Relevant Pages

  • Re: life-time pinning. vs Global heap
    ... Be sure to pin whatever you allocate, ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: life-time pinning. vs Global heap
    ... Be sure to pin whatever you allocate, ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A simple ADA puzzle (I havent the answer)
    ... > this type declaration would be to always allocate objects of this type off ... > of a heap, so that sizes could be adjusted as needed. ... That works better when you have multiple array ...
    (comp.lang.ada)
  • Re: life-time pinning. vs Global heap
    ... - Allocate a big byte array at the start of your program. ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ... If I want to "fix" an byte array for the life time of a program would it ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Heap vs Stack allocations
    ... > In all of these cases, it makes sense for the compiler to allocate x ... Storage for array x is allocated from the free store (the "heap") ...
    (comp.lang.c)