简体   繁体   中英

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM