DEV Community

yohhoy
yohhoy

Posted on

Juggling with asterisks(*) in C

To write C program, we can't avoid usage of the "Pointers" to manage null-terminated strigs, linked list structures, multidimensional arrays, etc. For instance, you might use double pointer -- pointer to pointer to type T, in short T** -- to handle dynamic allocated two-diminsional array, declare argv parameter of main function.

By the way, how many asterisk(*) of pointer type have you seen or written in practice?

As far as I know, there is pointer type with seven asterisks in ITU T-Rec. H.264.2 Reference Software.

Yes, it's "Septuple Pointer" with SEVEN(7) asterisks. It means "pointer to pointer to pointer to pointer to pointer to pointer to pointer to type T" in English, looks like T******* in C language.

// lcommon/src/memalloc.c
int get_mem6Dmv(MotionVector *******array6D,
                int dim0, int dim1, int dim2, int dim3, int dim4, int dim5)
Enter fullscreen mode Exit fullscreen mode
// lencod/src/slice.c
static int get_mem_bipred_mv(Slice *currSlice, MotionVector ******* bipred_mv)
{
  get_mem6Dmv(bipred_mv, 2, 2, currSlice->max_num_references, 9, 4, 4);
  return 576 * currSlice->max_num_references * sizeof(MotionVector);
}
Enter fullscreen mode Exit fullscreen mode

Side Note: The reference software also have "Octuple Pointer" with EIGHT(8) asterisks to handle seven-dimentional array. As good luck would have it, this function is not used any more!

// lcommon/src/memalloc.c
int get_mem7Dmv(MotionVector ********array7D,
                int dim0, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)