DEV Community

yohhoy
yohhoy

Posted on

3 1

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more