@@ -94,7 +94,7 @@ py::bytes DataListNode::get_data() {
9494}
9595
9696DataListNode *DataListCls::get (std::string key) {
97- for (int idx = 0 ; idx < list.size (); idx++) {
97+ for (size_t idx = 0 ; idx < list.size (); idx++) {
9898 DataListNode *node = &list[idx];
9999 if (strcmp (node->key .c_str (), key.c_str ()) == 0 ) {
100100 return node;
@@ -201,7 +201,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
201201 FSInotify *ino = new FSInotify ();
202202 pthread_t _pid;
203203 std::vector <std::string> s;
204- printf (" starting monitoring %s, pid is: %d \n " , wrapperFileAbs.c_str (), _pid);
204+ printf (" starting monitoring %s, pid is: %lu \n " , wrapperFileAbs.c_str (), _pid);
205205 s.push_back (wrapperFileAbs);
206206 std::map <std::string, EventHandle> funs;
207207
@@ -210,7 +210,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
210210 ino->InitWatchFile (s, this );
211211 int ret = ino->StartWatchThread (funs, _pid);
212212 if (ret != 0 ) {
213- printf (" Error starting monitoring %s, pid is: %d \n " , wrapperFileAbs.c_str (), _pid);
213+ printf (" Error starting monitoring %s, pid is: %lu \n " , wrapperFileAbs.c_str (), _pid);
214214 }
215215}
216216
@@ -297,7 +297,7 @@ int PyWrapper::wrapperOnceExec(const char *usrTag, std::map <std::string, std::s
297297 return ret;
298298 }
299299 ptr = PyBytes_AsString (itemData.data .ptr ());
300- Py_ssize_t size = PyBytes_GET_SIZE (itemData.data .ptr ());
300+ // Py_ssize_t size = PyBytes_GET_SIZE(itemData.data.ptr());
301301// printf("GetSIze, %d", size);
302302// printf("item data len: %d", itemData.len);
303303 memcpy (pr, ptr, itemData.len );
@@ -551,7 +551,7 @@ int PyWrapper::wrapperLoadRes(pDataList p, unsigned int resId) {
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 :{},resID:{}" , p->type , resId);
@@ -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 key: " << d.key << std::endl;
599599 // std::cout << "Response len" << d.len << std::endl;
@@ -616,7 +616,7 @@ int callbackMetric(const char *usrTag, const char *meterKey, int count) {
616616}
617617
618618int callbackTrace (const char *usrTag, const char *key, const char *value) {
619- printf (" callback Trace: %s, %s, %d \n " , usrTag, key, value);
619+ printf (" callback Trace: %s, %s, %s \n " , usrTag, key, value);
620620 return g_trace_cb (usrTag, key, value);
621621}
622622
@@ -629,8 +629,8 @@ int callBack(Response *resp, std::string sid) {
629629 }
630630 const char *usrTag = GetSidUsrTag (sid);
631631
632- pDataList headPtr;
633- pDataList curPtr;
632+ pDataList headPtr = nullptr ;
633+ pDataList curPtr = nullptr ;
634634 // 先判断python有没有抛出错误. response中的 errorCode
635635 if (resp->errCode != 0 ) {
636636 spdlog::get (" stderr_console" )->error (" find error from python: {}" , resp->errCode );
@@ -679,8 +679,20 @@ int callBack(Response *resp, std::string sid) {
679679 tmpData->status , sid);
680680 }
681681
682- cb_ (usrTag, headPtr, 0 );
683- printf (" ok\n :" );
682+ int cb_ret = cb_ (usrTag, headPtr, 0 );
683+ while (headPtr != nullptr ) {
684+ pDataList ptr = headPtr;
685+ headPtr = headPtr->next ;
686+ if (ptr->key ) {
687+ free (ptr->key );
688+ }
689+ if (ptr->data ) {
690+ free (ptr->data );
691+ }
692+ delete ptr;
693+ }
694+
695+ spdlog::debug (" call c's callback, usrTag:{} ret {}" ,usrTag, cb_ret);
684696 return 0 ;
685697
686698}
0 commit comments