diff --git a/general/src/debug.cpp b/general/src/debug.cpp index 79082d2..e8db350 100644 --- a/general/src/debug.cpp +++ b/general/src/debug.cpp @@ -28,7 +28,7 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ } snprintf(out,5,"LN: "); for (int z = 1;z < rowNum + 1; z++) { - char tmp[4] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%02d ",z); strcat(out,tmp); } @@ -36,7 +36,7 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ if (ifAsii) { for (int z = 1;z < rowNum + 1; z++) { - char tmp[4] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%02d ",z); strcat(out,tmp); } @@ -44,13 +44,13 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ strcat(out,"\r\n"); for(int i = 0;i < row;i ++) { string rowstr; - char tmp[3] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%02x",i + 1); rowstr += string(tmp) + ": "; //last row if (i == row -1 && left != 0){ for (int z = 0;z < rowNum; z++) { - char tmp[3] = {0}; + char tmp[6] = {0}; if (z < left){ sprintf(tmp,"%02x",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); }else{ @@ -65,7 +65,7 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ rowstr += " "; if(ifAsii) { for (int z = 0;z < left; z++) { - char tmp[3] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%c",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); rowstr += string(tmp) + " "; if (z == left - 1){ @@ -75,7 +75,7 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ } }else{ for (int z = 0;z < rowNum; z++) { - char tmp[3] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%02x",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); rowstr += string(tmp) + " "; if (!ifAsii){ @@ -84,10 +84,10 @@ int PrintDumpObjvoid (void *dst,int rowNum,int num,bool ifAsii){ } } } - rowstr += " "; if(ifAsii){ + rowstr += " "; for (int z = 0;z < rowNum; z++) { - char tmp[1] = {0}; + char tmp[6] = {0}; sprintf(tmp,"%c",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); rowstr += string(tmp) + " "; if (z == rowNum - 1){ @@ -129,13 +129,13 @@ int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out) { strcat(out,"\r\n"); for(int i = 0;i < row;i ++) { string rowstr; - char tmp[3] = {0}; + char tmp[4] = {0}; sprintf(tmp,"%02x",i + 1); rowstr += string(tmp) + ": "; //last row if (i == row -1 && left != 0){ for (int z = 0;z < rowNum; z++) { - char tmp[3] = {0}; + char tmp[4] = {0}; if (z < left){ sprintf(tmp,"%02x",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); }else{ @@ -150,7 +150,7 @@ int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out) { rowstr += " "; if(ifAsii) { for (int z = 0;z < left; z++) { - char tmp[3] = {0}; + char tmp[4] = {0}; sprintf(tmp,"%c",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); rowstr += string(tmp) + " "; if (z == left - 1){ @@ -172,7 +172,7 @@ int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out) { rowstr += " "; if(ifAsii){ for (int z = 0;z < rowNum; z++) { - char tmp[1] = {0}; + char tmp[4] = {0}; sprintf(tmp,"%c",((unsigned char)(((unsigned char *)dst)[ z + i * rowNum]))); rowstr += string(tmp) + " "; if (z == rowNum - 1){ diff --git a/general/src/function/threadpool.cpp b/general/src/function/threadpool.cpp index e0a3970..27dcfda 100644 --- a/general/src/function/threadpool.cpp +++ b/general/src/function/threadpool.cpp @@ -17,7 +17,6 @@ namespace general{ CThreadPool::CThreadPool(int num) { this->mThreadCnt = num; mStarted = false; - } int CThreadPool::AddTask(Task *t) { @@ -126,4 +125,3 @@ namespace general{ } } - diff --git a/test/src/cpp11/log_test.cpp b/test/src/cpp11/log_test.cpp index 1bf0ed0..e9f2585 100644 --- a/test/src/cpp11/log_test.cpp +++ b/test/src/cpp11/log_test.cpp @@ -1,10 +1,40 @@ #include "loger.h" +#include "debug.h" + +#pragma pack(4) +typedef struct test1{ + uint32_t a ; + uint32_t b; + char c; +}Test1; +#pragma pack() + +#pragma pack(1) +typedef struct testsize2{ + uint16_t a; + uint8_t b; + uint32_t c; +}Test2; +#pragma pack() int main(){ + std::cout< v; //调用常规的拷贝构造函数,新建字符数组,拷贝数据 @@ -267,13 +267,14 @@ class ASyncProcess { std::cout<<"ASyncProcess construct"<m_finish = true; + mMutex.unlock(); }); } bool Finish(){ return m_finish; } - virtual ~ASyncProcess() { mThread->detach(); } @@ -281,7 +282,6 @@ class ASyncProcess { bool m_finish = false; std::thread *mThread; std::mutex mMutex; - }; template diff --git a/test/src/cpp11/threadpool.cpp b/test/src/cpp11/threadpool.cpp index 6cdd0b8..36aad87 100644 --- a/test/src/cpp11/threadpool.cpp +++ b/test/src/cpp11/threadpool.cpp @@ -1,5 +1,4 @@ #include "threadpool.h" -// 参考于https://www.cnblogs.com/bigosprite/p/11071462.html unsigned int CoreCount() {