redefine hgl_cpy/hgl_move .... function name.

This commit is contained in:
2020-09-19 18:31:07 +08:00
parent 3e9b703ebc
commit 29785b9d2a
3 changed files with 20 additions and 11 deletions

View File

@@ -237,7 +237,7 @@ namespace hgl
template<typename T> T ToLittleEndian(T value){return value;} template<typename T> T ToLittleEndian(T value){return value;}
template<typename T> inline void ToLittleEndian(T *,const int64){} template<typename T> inline void ToLittleEndian(T *,const int64){}
template<typename D,typename S> inline void ToLittleEndian(D *dst,const S *src,const int64 count){hgl_cpy(dst,src,count);} template<typename D,typename S> inline void ToLittleEndian(D *dst,const S *src,const int64 count){typeconv(dst,src,count);}
#endif//HGL_BIG_ENDIAN #endif//HGL_BIG_ENDIAN

View File

@@ -505,7 +505,7 @@ namespace hgl
} }
/** /**
* 等值类型复制 * 类型复制
*/ */
template<typename T> template<typename T>
inline void hgl_cpy(T &dst,const T &src) inline void hgl_cpy(T &dst,const T &src)
@@ -514,10 +514,19 @@ namespace hgl
} }
/** /**
* 同类型数据复制 * 同类型指针数据复制
*/
template<typename T>
inline void hgl_cpy(T *dst,const T *src)
{
memcpy(dst,src,sizeof(T));
}
/**
* 数据类型转换赋值
*/ */
template<typename S,typename D> template<typename S,typename D>
inline void hgl_cpy(D *dst,const S *src,const size_t count) inline void typeconv(D *dst,const S *src,const size_t count)
{ {
for(size_t i=0;i<count;i++) for(size_t i=0;i<count;i++)
{ {
@@ -531,7 +540,7 @@ namespace hgl
* 同类型数据块复制 * 同类型数据块复制
*/ */
template<typename T> template<typename T>
inline void hgl_typecpy(T *dst,const T *src,const size_t count) inline void hgl_cpy(T *dst,const T *src,const size_t count)
{ {
memcpy(dst,src,count*sizeof(T)); memcpy(dst,src,count*sizeof(T));
} }
@@ -540,7 +549,7 @@ namespace hgl
* 同类型数据块移动 * 同类型数据块移动
*/ */
template<typename T> template<typename T>
inline void hgl_typemove(T *dst,const T *src,const size_t count) inline void hgl_move(T *dst,const T *src,const size_t count)
{ {
memmove(dst,src,count*sizeof(T)); memmove(dst,src,count*sizeof(T));
} }

View File

@@ -414,12 +414,12 @@ namespace hgl
T *new_str=new T[malloc_length]; T *new_str=new T[malloc_length];
if(pos) if(pos)
hgl_typecpy(new_str,buffer,pos); hgl_cpy(new_str,buffer,pos);
hgl_typecpy(new_str+pos,istr,len); hgl_cpy(new_str+pos,istr,len);
if(pos<length) if(pos<length)
hgl_typecpy(new_str+pos+len,buffer+pos,length-pos); hgl_cpy(new_str+pos+len,buffer+pos,length-pos);
new_str[need_length-1]=0; new_str[need_length-1]=0;
@@ -431,8 +431,8 @@ namespace hgl
} }
else else
{ {
hgl_typemove(buffer+pos+len,buffer+pos,length-pos+1); hgl_move(buffer+pos+len,buffer+pos,length-pos+1);
hgl_typecpy(buffer+pos,istr,len); hgl_cpy(buffer+pos,istr,len);
length+=len; length+=len;
} }