@@ -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 );
@@ -551,7 +551,7 @@ int PyWrapper::wrapperLoadRes(pDataList p, std::string patch_id) {
551551 item.data = py::bytes ((char *) (p->data ), len);
552552
553553 item.len = p->len ;
554- char t = static_cast <int >(p->type );
554+ // char t = static_cast<int>(p->type);
555555 item.type = p->type ;
556556 item.status = p->status ;
557557 spdlog::debug (" reqDatatype :{},patch_id:{}" , p->type , patch_id);
@@ -593,7 +593,7 @@ int PyWrapper::wrapperTest() {
593593 std::cout << e.what () << std::endl;
594594 return -1 ;
595595 }
596- for (int i = 0 ; i < l->list .size (); ++i) {
596+ for (size_t i = 0 ; i < l->list .size (); ++i) {
597597 ResponseData d = l->list [i];
598598 // std::cout << "Response len" << d.len << std::endl;
599599 // std::cout << "response actual data Size " << d.data.length() << std::endl;
@@ -615,7 +615,7 @@ int callbackMetric(const char *usrTag, const char *meterKey, int count) {
615615}
616616
617617int callbackTrace (const char *usrTag, const char *key, const char *value) {
618- printf (" callback Trace: %s, %s, %d \n " , usrTag, key, value);
618+ printf (" callback Trace: %s, %s, %s \n " , usrTag, key, value);
619619 return g_trace_cb (usrTag, key, value);
620620}
621621
@@ -626,8 +626,8 @@ int callBack(Response *resp, char *usrTag) {
626626 printf (" null cb....\n " );
627627 return -1 ;
628628 }
629- pDataList headPtr;
630- pDataList curPtr;
629+ pDataList headPtr = nullptr ;
630+ pDataList curPtr = nullptr ;
631631 int ret ;
632632 // 先判断python有没有抛出错误. response中的 errorCode
633633 if (resp->errCode != 0 ) {
@@ -679,7 +679,19 @@ int callBack(Response *resp, char *usrTag) {
679679 }
680680
681681 int cb_ret = cb_ (usrTag, headPtr, 0 );
682- spdlog::debug (" call c's callback,usrTag:{} ret {}" ,usrTag, cb_ret);
682+ while (headPtr != nullptr ) {
683+ pDataList ptr = headPtr;
684+ headPtr = headPtr->next ;
685+ if (ptr->key ) {
686+ free (ptr->key );
687+ }
688+ if (ptr->data ) {
689+ free (ptr->data );
690+ }
691+ delete ptr;
692+ }
693+
694+ spdlog::debug (" call c's callback, usrTag:{} ret {}" ,usrTag, cb_ret);
683695 return 0 ;
684696
685697}
0 commit comments