weird code.



1: float (*data)[16384];
2: data = malloc(31 * sizeof(data[0]));
3: data[i][j] = VARIABLE;

Question 1: The variable data is a float pointer?

Question 2: When the [16384] is used. Does that mean it is an array of
float pointers? What does it mean?

Question 3: Or does it mean that there are 16384 floats allocated with
the pointer data that points to the head of those 16384 floats?

Question 4: It will malloc 31*16384 floats... I assume this is true
based on how the program uses it. But shouldn't it be mallocing
31*sizeof(float*)?

Question 5: Then the code starts using data as a multidimensional
array. When did it become a multidimensional array?! and how did it
become multidimensional?!

.



Relevant Pages

  • Re: Getting a function to return an array
    ... I am trying to write a function which takes several floats as ... then returns 1x6 array of floats. ... The "unsafe" way to have that agreement is ...
    (comp.lang.c)
  • Re: converting to bits
    ... > Does C have some handy functions to convert chars, ints and floats to bit ... what type of array would you want to store ...
    (comp.lang.c)
  • Re: List<t> generic type - Fastest way to copy into an unmanaged array?
    ... > floats into an unmanaged array of floats. ... > As far as the managed collection is implemented, ... > boxing/unboxing issues. ...
    (microsoft.public.dotnet.languages.vc)
  • List<t> generic type - Fastest way to copy into an unmanaged array?
    ... floats into an unmanaged array of floats. ... As far as the managed collection is implemented, ... fast way of copying a tradional managed array into an unmanaged array. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: optimizing simple-arrays
    ... I'd expect your get-floatN routines to ... have to perform the array lookup at each reference, ... You might do better, also, to have maxvalue as single floats ... > function was the exact bottleneck, so I just optimized the whole thing ...
    (comp.lang.lisp)