@@ -95,7 +95,7 @@ py::bytes DataListNode::get_data() {
9595}
9696
9797DataListNode *DataListCls::get (std::string key) {
98- for (int idx = 0 ; idx < list.size (); idx++) {
98+ for (size_t idx = 0 ; idx < list.size (); idx++) {
9999 DataListNode *node = &list[idx];
100100 if (strcmp (node->key .c_str (), key.c_str ()) == 0 ) {
101101 return node;
@@ -203,7 +203,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
203203 FSInotify *ino = new FSInotify ();
204204 pthread_t _pid;
205205 std::vector <std::string> s;
206- printf (" starting monitoring %s, pid is: %d \n " , wrapperFileAbs.c_str (), _pid);
206+ printf (" starting monitoring %s, pid is: %lu \n " , wrapperFileAbs.c_str (), _pid);
207207 s.push_back (wrapperFileAbs);
208208 std::map <std::string, EventHandle> funs;
209209
@@ -212,7 +212,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
212212 ino->InitWatchFile (s, this );
213213 int ret = ino->StartWatchThread (funs, _pid);
214214 if (ret != 0 ) {
215- printf (" Error starting monitoring %s, pid is: %d \n " , wrapperFileAbs.c_str (), _pid);
215+ printf (" Error starting monitoring %s, pid is: %lu \n " , wrapperFileAbs.c_str (), _pid);
216216 }
217217}
218218
@@ -299,7 +299,7 @@ int PyWrapper::wrapperOnceExec(const char *usrTag, std::map <std::string, std::s
299299 return ret;
300300 }
301301 ptr = PyBytes_AsString (itemData.data .ptr ());
302- Py_ssize_t size = PyBytes_GET_SIZE (itemData.data .ptr ());
302+ // Py_ssize_t size = PyBytes_GET_SIZE(itemData.data.ptr());
303303// printf("GetSIze, %d", size);
304304// printf("item data len: %d", itemData.len);
305305 memcpy (pr, ptr, itemData.len );
@@ -550,7 +550,7 @@ int PyWrapper::wrapperLoadRes(pDataList p, std::string patch_id) {
550550 item.data = py::bytes ((char *) (p->data ), len);
551551
552552 item.len = p->len ;
553- char t = static_cast <int >(p->type );
553+ // char t = static_cast<int>(p->type);
554554 item.type = p->type ;
555555 item.status = p->status ;
556556 spdlog::debug (" reqDatatype :{},patch_id:{}" , p->type , patch_id);
@@ -592,7 +592,7 @@ int PyWrapper::wrapperTest() {
592592 std::cout << e.what () << std::endl;
593593 return -1 ;
594594 }
595- for (int i = 0 ; i < l->list .size (); ++i) {
595+ for (size_t i = 0 ; i < l->list .size (); ++i) {
596596 ResponseData d = l->list [i];
597597 // std::cout << "Response len" << d.len << std::endl;
598598 // std::cout << "response actual data Size " << d.data.length() << std::endl;
@@ -614,7 +614,7 @@ int callbackMetric(const char *usrTag, const char *meterKey, int count) {
614614}
615615
616616int callbackTrace (const char *usrTag, const char *key, const char *value) {
617- printf (" callback Trace: %s, %s, %d \n " , usrTag, key, value);
617+ printf (" callback Trace: %s, %s, %s \n " , usrTag, key, value);
618618 return g_trace_cb (usrTag, key, value);
619619}
620620
@@ -625,8 +625,8 @@ int callBack(Response *resp, char *usrTag) {
625625 printf (" null cb....\n " );
626626 return -1 ;
627627 }
628- pDataList headPtr;
629- pDataList curPtr;
628+ pDataList headPtr = nullptr ;
629+ pDataList curPtr = nullptr ;
630630 int ret ;
631631 // 先判断python有没有抛出错误. response中的 errorCode
632632 if (resp->errCode != 0 ) {
@@ -678,7 +678,19 @@ int callBack(Response *resp, char *usrTag) {
678678 }
679679
680680 int cb_ret = cb_ (usrTag, headPtr, 0 );
681- spdlog::debug (" call c's callback,usrTag:{} ret {}" ,usrTag, cb_ret);
681+ while (headPtr != nullptr ) {
682+ pDataList ptr = headPtr;
683+ headPtr = headPtr->next ;
684+ if (ptr->key ) {
685+ free (ptr->key );
686+ }
687+ if (ptr->data ) {
688+ free (ptr->data );
689+ }
690+ delete ptr;
691+ }
692+
693+ spdlog::debug (" call c's callback, usrTag:{} ret {}" ,usrTag, cb_ret);
682694 return 0 ;
683695
684696}
0 commit comments