Dave
Dave

Reputation: 23

Passing a pointer as an parameter, memory usage

i have a question concerning pointers.

What is the difference between these 2 options when it comes to memory usage. I've tried both and nothing has changed when it comes to my memory. I thought that the first would receive a pointer to the adress of the allocated memory, and the second would receive a copy.

    check_ret = check_tetrimino(&grid, *curr, ind_y, ind_x);
int         check_tetrimino(char ***grid, t_tetrimino curr, int ind_y, int ind_x)

or

    check_ret = check_tetrimino(grid, *curr, ind_y, ind_x);
int         check_tetrimino(char **grid, t_tetrimino curr, int ind_y, int ind_x)

Upvotes: 0

Views: 73

Answers (1)

Nikos C.
Nikos C.

Reputation: 51832

It's a pointer in both cases. char *** is a pointer, and so is char **, and both have the same size:

sizeof(char**) == sizeof(char***)

So the amount of bytes copied for the two different function calls is the same in both cases. Obviously the pointers that the function receives point to different things, but this doesn't change the size of the function parameters.

Upvotes: 1

Related Questions