[C] What's pointers like *** mean?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
triple dereference

Hi all,

I am reading a reference software of H.264 video encoder (http://iphome.hhi.de/suehring/tml/download/).


And I found a lot of variable are declared like below:
imgpel **imgY = p->imgY;
imgpel ***imgUV = p->imgUV;
There are even six pointers ******.

What's pointers like *** mean? Is it pointer to a structure and so on?

How can I know where does the pointer point to?

And why use this style, is it convenient?

Best regards,
Davy
 

The dereference operator (*) allows you to access the data that the pointer is pointing to.

E.g.
pPointer = 0; // sets the pointer to zero.
*pPointer = 0; // sets the memory pointed to by pPointer to zero.

Sometimes its necessary and convenient to double or triple dereference pointers to access data in structures or arrays. I have a queuing system in C that uses arrays of pointers. Each pointer, points to a structure. Now to access the queue I use a Head and Tail pointer. Accessing the data in the queue can be done through the use of a double dereference pointer.

E.g.
*pTail // Points to the memory address in the queue.
**pTail->access structure on heap // Points to the data at the memory address in the queue.

Hope that helps
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
hi ,may be multi dimentional arrays!
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
You can have a pointer to a pointer, or a pointer to a pointer to a pointer ect, ect. If you take notice of misra rules, they advise that you should not use more than 2 levels of indirection as it then becomes difficult to understand the code.
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…