What exactly is an 'aligned pointer'?

前端 未结 6 1934
执笔经年
执笔经年 2020-11-29 22:28

Would somebody please tell me what an aligned pointer actually means?

6条回答
  •  我在风中等你
    2020-11-29 22:53

    As people have mentioned before me it means that your pointer is evenly divisible by a certain number of bytes.

    To check if your pointer is aligned you can do this:

    isaligned = !( (long)pointer % bytes );
    

    Now, "isaligned" is true if "pointer" is aligned to "bytes" bytes.

提交回复
热议问题