Wednesday, March 30, 2011

memcpy vs strcpy

Today my team had problem with the memory when allocating a new CLabel. I figured the problem and it was because i was using strcpy when I should've been using memcpy! I know stupid eh but yea. After a little research i decided to implement memcpy into my code when i shouldve implemented it long time ago. Here's what I found out about memcpy vs strcpy.

memcpy is much more efficient when handling things like void* (that's what _data is in the CField class). It's also a more general type of copying while strcpy is strictly strings. memcpy also takes an extra argument that specifies how much bytes to copy (Really useful in CLabel::set function). That is all.

No comments:

Post a Comment