Copying structure in C with assignment instead of memcpy()

后端 未结 5 1138
孤街浪徒
孤街浪徒 2020-12-08 15:07

Up until recently, I have only seen copying of structure fields done with memcpy(). In classes and online instructions, copying the contents of one struct into

5条回答
  •  情深已故
    2020-12-08 15:36

    This could not be the exact answer you looking for.

    Im explaining scenario which I met.

    when we use memcpy(), it does byte-by-byte copy to destination. so no worry about data alignment in ARM architecture. If you use = operator, and any one of the address is not aligned to 4-byte then alignment fault will come.

    From Arm site:

    A pointer to the destination location that is one byte beyond the last byte written to. This enables continuation of the writing process with perfect alignment of bytes for string concatenation of memory blocks.

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0175k/Cihbbjge.html

提交回复
热议问题