我的memcmp:
memcmp( *buf1, *buf2, unsigned (count && !(reval = (*(unsigned *)buf1) - (*(unsigned * buf1 = (unsigned *)buf1 + buf2 = (unsigned *)buf2 + -- }
MS VC:
* * (!( ( --count && *( *)buf1 == *( *= ( *)buf1 + = ( *)buf2 + ( *((unsigned *)buf1) - *((unsigned *
應該使用const void *buf為宜,不改變該塊內存的內容,最終使用unsigned char *進行運算,保證運算結果的符號正確。
我的memcpy:
*memcpy( *dest, *src, unsigned *reval = (count-- (*(unsigned *)dest++) = (*(unsigned *)src++ }
MSVC:
* * * * ret = defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) RtlMoveMemory( *, * /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ (count-- *( *)dst = *( * dst = ( *)dst + src = ( *)src + /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ }
我的memmove:
*memmove( *dest, *src, unsigned *reval = overlap = ((unsigned *)src < (unsigned *)dest && ((unsigned *)src + count) > (count-- (overlap) (*((unsigned *)dest + count)) = (*((unsigned *)src + count (*(unsigned *)dest++) = (*(unsigned *)src++ }
MSVC:
* * * * ret = defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) RtlMoveMemory( *, * /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ (dst <= src || ( *)dst >= (( *)src + (count-- *( *)dst = *( * dst = ( *)dst + src = ( *)src + dst = ( *)dst + count - src = ( *)src + count - (count-- *( *)dst = *( * dst = ( *)dst - src = ( *)src - /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ }
關於memcpy和memmove的區別,memcpy不考慮內存區域重疊的情況而memmove保證內存區域重疊也能正常復制成功。
有時候我們的memcpy也可能在內存重疊的情況下正常使用,這取決於它的實現,不具有普遍性,C語言標准中未對其有這種要求。
參考資料:
《關於memcpy和memmove兩函數的區別》
http://blog.csdn.net/caowei840701/article/details/8491836
《memcpy() vs memmove()》
http://stackoverflow.com/questions/4415910/memcpy-vs-memmove
我的memset:
*memset( *buffer, c, *reval = (count-- (*(unsigned *)buffer++) = (unsigned }
MSVC:
* * *start = defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) RtlFillMemory( *, size_t count, RtlFillMemory( dst, count, ( /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ (count-- *( *)dst = ( dst = ( *)dst + /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */ }
完