修正拷贝设置函数的BUG

This commit is contained in:
Stone 2016-06-07 10:03:08 +00:00
parent fe839afa6e
commit 4c3e3fbe45
5 changed files with 11 additions and 16 deletions

View File

@ -1,6 +1,4 @@
//#include <string.h>
#include "_Core.h"
#include "_Core.h"
#include "Type.h"
#include "Buffer.h"

View File

@ -1,6 +1,4 @@
//#include <string.h>
#include "_Core.h"
#include "_Core.h"
#include "Buffer.h"
#include "SString.h"
@ -347,7 +345,7 @@ int Buffer::CompareTo(const Buffer& bs) const
int Buffer::CompareTo(const void* ptr, int len) const
{
if(len < 0) len = 0xFFFF;
if(len < 0) len = _Length;
// 同一个指针,长度决定大小
if(_Arr == ptr) return _Length - len;
@ -408,7 +406,7 @@ void memset(byte* ptr, byte item, uint len)
// 为了让中间部分凑够4字节对齐
int n = (uint)p & 0x03;
for(int i=0; i<n && len>0; i++, len--)
while(n-- && len--)
*p++ = item;
// 中间部分4字节对齐
@ -416,9 +414,11 @@ void memset(byte* ptr, byte item, uint len)
{
int v = (item << 24) | (item << 16) | (item << 8) | item;
int* pi = (int*)p;
for(; len>0; len-=4)
n = len >> 2;
while(n--)
*pi++ = v;
p = (byte*)pi;
len &= 0x03;
}
// 结尾部分
@ -436,7 +436,7 @@ void memcpy(byte* dst, const byte* src, uint len)
if(nd == ns)
{
// 为了让中间部分凑够4字节对齐
for(int i=0; i<nd && len>0; i++, len--)
while(nd-- && len--)
*dst++ = *src++;
// 中间部分4字节对齐
@ -444,10 +444,12 @@ void memcpy(byte* dst, const byte* src, uint len)
{
int* pd = (int*)dst;
int* ps = (int*)src;
for(; len>0; len-=4)
ns = len >> 2;
while(ns--)
*pd++ = *ps++;
dst = (byte*)pd;
src = (byte*)ps;
len &= 0x03;
}
}

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>

View File

@ -1,7 +1,5 @@
#include "BinaryPair.h"
//#include <string.h>
// 初始化消息各字段为0
/*BinaryPair::BinaryPair(Buffer& bs)
{

View File

@ -1,7 +1,5 @@
#include "Sys.h"
//#include <string.h>
#if DEBUG
static void TestAssign()
{