From e25f3e440ed00d597a9802df68adedadb629d814 Mon Sep 17 00:00:00 2001 From: cheliequan <liequanche@126.com> Date: 星期五, 13 一月 2023 12:10:06 +0800 Subject: [PATCH] 1.增加获取系统授权接口 2.完善相机相关函数实现 3.优化内存释放 --- util.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 51 insertions(+), 4 deletions(-) diff --git a/util.cpp b/util.cpp index 9eedab4..d7f1e5f 100644 --- a/util.cpp +++ b/util.cpp @@ -145,12 +145,14 @@ if (bus_client_request(handle, reqmsg, pptr_repmsg)) { printf("======>> bus_client_reqest [%s] get [%s]\n", topic, (*pptr_repmsg)->data); } else { + free(reqData); return false; } len = strlen((*pptr_repmsg)->data) + 1; - free(reqData); + free(reqData); + return true; } @@ -158,6 +160,7 @@ yyjson_type type = YYJSON_TYPE_OBJ; crepmsg *repmsg = NULL; size_t len = 0; + bool bRet = false; bus_dbapi_get_topic_data(handle, topic, &repmsg, len); @@ -171,19 +174,63 @@ } std::string jsonString = msgdata; - if (json_to_proto(jsonString, message)) + bRet = json_to_proto(jsonString, message); + if (bRet) { printf("======>> json_to_proto done\n"); } else { printf("======>> json_to_proto fail\n"); - return false; } free(msgdata); free_reply_msg(repmsg); - return true; + return bRet; } +/***************************************************************************** + 鍑� 鏁� 鍚� : bus_dbapi_get_str + 鍔熻兘鎻忚堪 : 鑾峰彇璁㈤槄涓婚娑堟伅瀛楃涓诧紝杩斿洖鐨勫唴瀛樿皟鐢ㄨ�呴渶瑕佹墜宸ヨ皟鐢╢ree鍑芥暟閲婃斁 + 杈撳叆鍙傛暟 : void *handle + const char* topic + char **pptr_str + 杈撳嚭鍙傛暟 : 鏃� + 杩� 鍥� 鍊� : + 璋冪敤鍑芥暟 : + 琚皟鍑芥暟 : + + 淇敼鍘嗗彶 : + 1.鏃� 鏈� : 2023骞�1鏈�13鏃� + 浣� 鑰� : cheliequan + 淇敼鍐呭 : 鏂扮敓鎴愬嚱鏁� + +*****************************************************************************/ +bool bus_dbapi_get_str(void *handle, const char* topic, char **pptr_str) { + yyjson_type type = YYJSON_TYPE_OBJ; + crepmsg *repmsg = NULL; + size_t len = 0; + int iRet = 0; + bool bRet = false; + + bus_dbapi_get_topic_data(handle, topic, &repmsg, len); + + int msglen = strlen(repmsg->data); + char* msgdata = (char *)malloc(msglen); + memset(msgdata, 0 , msglen); + + iRet = bus_dbapi_get_json_data((const char *)repmsg->data, &msgdata, &type); + if(0 == iRet) + { + printf("======>> protomsg: %s\n", msgdata); + bRet = true; + } + + *pptr_str = msgdata; + + free(msgdata); + free_reply_msg(repmsg); + + return bRet; +} -- Gitblit v1.8.0