Thread: help undestanding what pointer is being passed

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    11

    help undestanding what pointer is being passed

    Hello,

    I am refactoring some code that uses a non-GPL'ed FFT function (will replace with fftw), but I don't yet understand what exactly is being passed. Specifically, I don't understand what is pointed to when you pass "*pointer -1", as shown below:

    My fft buffer is allocated with:
    pFFftBuffer = (float *) calloc(sizeFft+1, sizeof(float));

    and then passed to the fft function with:
    realft (pFFftBuffer-1, sizeMag, -1);

    realft is defined as:
    void realft(float *data, int n, int isign);

    If anyone could help me understand what data realft is receiving, I would be deeply thankful.

    regards,
    Rich

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Specifically, I don't understand what is pointed to when you pass "*pointer -1", as shown below:
    I'm guessing realft() never refers to location 0 of the array (data[0]). This function is probably written to start with an array based at location 1. This is why the calloc() allocates an extra array location (sizeFft+1), as location 1 of the array is never used.

    Strictly speaking, passing pFFftBuffer-1 to the function is not defined by the C Standard, so the code is not portable. However it's likely to work on most platforms.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why does C need pointer conversion
    By password636 in forum C Programming
    Replies: 2
    Last Post: 04-10-2009, 07:33 AM
  2. What is a virtual function pointer?
    By ting in forum C++ Programming
    Replies: 4
    Last Post: 03-05-2008, 02:36 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Multithreads & Pointer to bool :: MFC
    By kuphryn in forum Windows Programming
    Replies: 7
    Last Post: 06-26-2002, 10:50 AM