@@ -95,7 +95,7 @@ py::bytes DataListNode::get_data() {
95
95
}
96
96
97
97
DataListNode *DataListCls::get (std::string key) {
98
- for (int idx = 0 ; idx < list.size (); idx++) {
98
+ for (size_t idx = 0 ; idx < list.size (); idx++) {
99
99
DataListNode *node = &list[idx];
100
100
if (strcmp (node->key .c_str (), key.c_str ()) == 0 ) {
101
101
return node;
@@ -203,7 +203,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
203
203
FSInotify *ino = new FSInotify ();
204
204
pthread_t _pid;
205
205
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);
207
207
s.push_back (wrapperFileAbs);
208
208
std::map <std::string, EventHandle> funs;
209
209
@@ -212,7 +212,7 @@ void PyWrapper::StartMonitorWrapperClass(std::string wrapperFileAbs) {
212
212
ino->InitWatchFile (s, this );
213
213
int ret = ino->StartWatchThread (funs, _pid);
214
214
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);
216
216
}
217
217
}
218
218
@@ -299,7 +299,7 @@ int PyWrapper::wrapperOnceExec(const char *usrTag, std::map <std::string, std::s
299
299
return ret;
300
300
}
301
301
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());
303
303
// printf("GetSIze, %d", size);
304
304
// printf("item data len: %d", itemData.len);
305
305
memcpy (pr, ptr, itemData.len );
@@ -551,7 +551,7 @@ int PyWrapper::wrapperLoadRes(pDataList p, std::string patch_id) {
551
551
item.data = py::bytes ((char *) (p->data ), len);
552
552
553
553
item.len = p->len ;
554
- char t = static_cast <int >(p->type );
554
+ // char t = static_cast<int>(p->type);
555
555
item.type = p->type ;
556
556
item.status = p->status ;
557
557
spdlog::debug (" reqDatatype :{},patch_id:{}" , p->type , patch_id);
@@ -593,7 +593,7 @@ int PyWrapper::wrapperTest() {
593
593
std::cout << e.what () << std::endl;
594
594
return -1 ;
595
595
}
596
- for (int i = 0 ; i < l->list .size (); ++i) {
596
+ for (size_t i = 0 ; i < l->list .size (); ++i) {
597
597
ResponseData d = l->list [i];
598
598
// std::cout << "Response len" << d.len << std::endl;
599
599
// 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) {
615
615
}
616
616
617
617
int 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);
619
619
return g_trace_cb (usrTag, key, value);
620
620
}
621
621
@@ -626,8 +626,8 @@ int callBack(Response *resp, char *usrTag) {
626
626
printf (" null cb....\n " );
627
627
return -1 ;
628
628
}
629
- pDataList headPtr;
630
- pDataList curPtr;
629
+ pDataList headPtr = nullptr ;
630
+ pDataList curPtr = nullptr ;
631
631
int ret ;
632
632
// 先判断python有没有抛出错误. response中的 errorCode
633
633
if (resp->errCode != 0 ) {
@@ -679,7 +679,19 @@ int callBack(Response *resp, char *usrTag) {
679
679
}
680
680
681
681
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);
683
695
return 0 ;
684
696
685
697
}
0 commit comments