Matthew 7 months ago
parent a7e4fabe13
commit 2653290682

@ -706,10 +706,7 @@ char Gm_GetSensorsPowerState(int port)
void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag) void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag)
{ {
int i; int i;
// char szbuf[4096]; char szbuf[4096];
char* szbuf = new char[4096];
std::unique_ptr<char[]> bufptr(szbuf);
memset(szbuf, 0, sizeof(szbuf)); memset(szbuf, 0, sizeof(szbuf));
if (NULL != describe) if (NULL != describe)
@ -746,8 +743,7 @@ void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag)
void Gm_OpenSerialPort(int devidx) void Gm_OpenSerialPort(int devidx)
{ {
int fd = -1; int fd = -1;
char* szbuf = new char[512]; char szbuf[512];
std::unique_ptr<char[]> bufptr(szbuf);
if ((devidx < 0) || (devidx >= MAX_SERIAL_DEV_NUM)) if ((devidx < 0) || (devidx >= MAX_SERIAL_DEV_NUM))
return; return;
@ -796,8 +792,7 @@ void Gm_CloseSerialPort()
int GM_SerialComSend(unsigned char * cSendBuf, size_t nSendLen, int commid) int GM_SerialComSend(unsigned char * cSendBuf, size_t nSendLen, int commid)
{ {
int i, len; int i, len;
char* szbuf = new char[512]; char szbuf[512];
std::unique_ptr<char[]> bufptr(szbuf);
memset(szbuf, 0, sizeof(szbuf)); memset(szbuf, 0, sizeof(szbuf));
len = write(serialport[commid].fd, cSendBuf, (size_t)nSendLen);/* 向串囗发送字符串 */ len = write(serialport[commid].fd, cSendBuf, (size_t)nSendLen);/* 向串囗发送字符串 */
@ -1705,9 +1700,7 @@ void GM_IsCloseSensors()
void GM_AllSerialComRecv() void GM_AllSerialComRecv()
{ {
int i, j, recvlen; int i, j, recvlen;
u_char* recvbuf = new u_char[RECVDATA_MAXLENTH]; u_char recvbuf[RECVDATA_MAXLENTH];
std::unique_ptr<u_char[]> recvbufptr(recvbuf);
char buf[256]; char buf[256];
for (j = 0; j < MAX_SERIAL_PORT_NUM; j++) for (j = 0; j < MAX_SERIAL_PORT_NUM; j++)
@ -1739,7 +1732,7 @@ void GM_AllSerialComRecv()
int GM_CloseTimer() int GM_CloseTimer()
{ {
int i, j, iretime; int i, j, iretime;
char buf[32]; char buf[256];
for (i = 0; i < MAX_SERIAL_DEV_NUM; i++) for (i = 0; i < MAX_SERIAL_DEV_NUM; i++)
{ {
@ -1817,17 +1810,7 @@ int SaveLogTofile(int commid, char *szbuf)
{ {
int status; int status;
time_t now; time_t now;
char filename[512], filedir[512], buf[128];
// char filename[512], filedir[512], buf[128];
char* filename = new char[512];
char* filedir = new char[512];
char* buf = new char[128];
std::unique_ptr<char[]> fnptr(filename);
std::unique_ptr<char[]> fdptr(filedir);
std::unique_ptr<char[]> bufptr(buf);
FILE *fp = NULL; FILE *fp = NULL;
struct tm t0; struct tm t0;
struct timeval tv; struct timeval tv;
@ -1873,7 +1856,7 @@ int SaveImageDataTofile(int devno)
u_char *image = NULL, *tempphoto = NULL; u_char *image = NULL, *tempphoto = NULL;
int i, status; int i, status;
size_t len; size_t len;
char szbuf[32]; char filename[512]/*, filedir[512]*/, szbuf[128];
FILE *fp = NULL; FILE *fp = NULL;
SERIAL_DEV_DEF *pPortParam; SERIAL_DEV_DEF *pPortParam;
@ -3411,8 +3394,7 @@ int Gm_CtrlPtzCmd(u_char channel, uint32_t ptzcmd)
time_t now = time(NULL); time_t now = time(NULL);
DIR *dir = opendir(path); DIR *dir = opendir(path);
struct dirent *entry; struct dirent *entry;
char* szbuf = new char[1024]; char szbuf[1024];
std::unique_ptr<char[]> szbufptr(szbuf);
char fullpath[256]; char fullpath[256];
memset(szbuf, 0, sizeof(szbuf)); memset(szbuf, 0, sizeof(szbuf));

Loading…
Cancel
Save