mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 00:41:17 +02:00
use new for buf, fix possible memlaek
This commit is contained in:
@@ -3948,7 +3948,7 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie)
|
|||||||
char spart[255];
|
char spart[255];
|
||||||
char dpart[255];
|
char dpart[255];
|
||||||
char npart[255];
|
char npart[255];
|
||||||
unsigned char * buf;
|
|
||||||
unsigned char psi[PSI_SIZE];
|
unsigned char psi[PSI_SIZE];
|
||||||
int r, i;
|
int r, i;
|
||||||
off64_t sdone, spos;
|
off64_t sdone, spos;
|
||||||
@@ -3965,9 +3965,9 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie)
|
|||||||
time_t tt1;
|
time_t tt1;
|
||||||
off64_t bpos, bskip;
|
off64_t bpos, bskip;
|
||||||
|
|
||||||
buf = (unsigned char *) malloc(BUF_SIZE);
|
unsigned char * buf = new unsigned char[BUF_SIZE];
|
||||||
if(buf == 0) {
|
if(buf == 0) {
|
||||||
perror("malloc");
|
perror("new");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4019,7 +4019,10 @@ printf("cut: end bookmark %d at %lld\n", bcount, books[bcount].pos);
|
|||||||
bcount++;
|
bcount++;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if(!bcount) return 0;
|
if(!bcount){
|
||||||
|
delete [] buf;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
qsort(books, bcount, sizeof(struct mybook), compare_book);
|
qsort(books, bcount, sizeof(struct mybook), compare_book);
|
||||||
for(i = 0; i < bcount; i++) {
|
for(i = 0; i < bcount; i++) {
|
||||||
if(books[i].ok) {
|
if(books[i].ok) {
|
||||||
@@ -4051,6 +4054,7 @@ printf("\n********* new file %s expected size %lld, start time %s", dpart, newsi
|
|||||||
dstfd = open (dpart, O_CREAT|O_WRONLY|O_TRUNC| O_LARGEFILE, 0644);
|
dstfd = open (dpart, O_CREAT|O_WRONLY|O_TRUNC| O_LARGEFILE, 0644);
|
||||||
if(dstfd < 0) {
|
if(dstfd < 0) {
|
||||||
perror(dpart);
|
perror(dpart);
|
||||||
|
delete [] buf;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
part = 0;
|
part = 0;
|
||||||
@@ -4179,7 +4183,7 @@ printf("********* total written %lld tooks %ld secs end time %s", spos, tt1-tt,
|
|||||||
lseek64 (dstfd, 0, SEEK_SET);
|
lseek64 (dstfd, 0, SEEK_SET);
|
||||||
ret_err:
|
ret_err:
|
||||||
close(dstfd);
|
close(dstfd);
|
||||||
free(buf);
|
delete [] buf;
|
||||||
if(was_cancel)
|
if(was_cancel)
|
||||||
g_RCInput->postMsg(CRCInput::RC_home, 0);
|
g_RCInput->postMsg(CRCInput::RC_home, 0);
|
||||||
return retval;
|
return retval;
|
||||||
@@ -4195,7 +4199,6 @@ static off64_t copy_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi
|
|||||||
char spart[255];
|
char spart[255];
|
||||||
char dpart[255];
|
char dpart[255];
|
||||||
char npart[255];
|
char npart[255];
|
||||||
unsigned char * buf;
|
|
||||||
unsigned char psi[PSI_SIZE];
|
unsigned char psi[PSI_SIZE];
|
||||||
int r, i;
|
int r, i;
|
||||||
off64_t sdone, spos = 0, btotal = 0;
|
off64_t sdone, spos = 0, btotal = 0;
|
||||||
@@ -4209,9 +4212,9 @@ static off64_t copy_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi
|
|||||||
bool was_cancel = false;
|
bool was_cancel = false;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
buf = (unsigned char *) malloc(BUF_SIZE);
|
unsigned char * buf = new unsigned char[BUF_SIZE];
|
||||||
if(buf == 0) {
|
if(buf == 0) {
|
||||||
perror("malloc");
|
perror("new");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4247,8 +4250,10 @@ printf("copy: jump bookmark %d at %lld len %lld\n", bcount, books[bcount].pos, b
|
|||||||
bcount++;
|
bcount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!bcount) return 0;
|
if(!bcount){
|
||||||
|
delete [] buf;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
tt = time(0);
|
tt = time(0);
|
||||||
printf("********* %d boormarks, to %s file(s), expected size to copy %lld, start time %s", bcount, onefile ? "one" : "many", newsize, ctime (&tt));
|
printf("********* %d boormarks, to %s file(s), expected size to copy %lld, start time %s", bcount, onefile ? "one" : "many", newsize, ctime (&tt));
|
||||||
snprintf(npart, sizeof(npart), "%s", name);
|
snprintf(npart, sizeof(npart), "%s", name);
|
||||||
@@ -4389,7 +4394,7 @@ printf("copy: ********* %s: total written %lld took %ld secs\n", dpart, spos, tt
|
|||||||
}
|
}
|
||||||
retval = 1;
|
retval = 1;
|
||||||
ret_err:
|
ret_err:
|
||||||
free(buf);
|
delete [] buf;
|
||||||
if(was_cancel)
|
if(was_cancel)
|
||||||
g_RCInput->postMsg(CRCInput::RC_home, 0);
|
g_RCInput->postMsg(CRCInput::RC_home, 0);
|
||||||
return retval;
|
return retval;
|
||||||
|
@@ -776,8 +776,6 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
|
|||||||
/*
|
/*
|
||||||
* some definition
|
* some definition
|
||||||
*/
|
*/
|
||||||
#define TS_LEN 188
|
|
||||||
#define TS_BUF_SIZE (TS_LEN * 2048) /* fix dmx buffer size */
|
|
||||||
|
|
||||||
static unsigned long timeval_to_ms (const struct timeval *tv)
|
static unsigned long timeval_to_ms (const struct timeval *tv)
|
||||||
{
|
{
|
||||||
@@ -789,7 +787,6 @@ long delta_time_ms (struct timeval *tv, struct timeval *last_tv)
|
|||||||
return timeval_to_ms (tv) - timeval_to_ms (last_tv);
|
return timeval_to_ms (tv) - timeval_to_ms (last_tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t b_total;
|
|
||||||
static cDemux * dmx;
|
static cDemux * dmx;
|
||||||
|
|
||||||
int CStreamInfo2::ts_setup ()
|
int CStreamInfo2::ts_setup ()
|
||||||
@@ -804,13 +801,22 @@ int CStreamInfo2::ts_setup ()
|
|||||||
if( !g_RemoteControl->current_PIDs.APIDs.empty() )
|
if( !g_RemoteControl->current_PIDs.APIDs.empty() )
|
||||||
apid = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].pid;
|
apid = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].pid;
|
||||||
|
|
||||||
|
short ret = -1;
|
||||||
if(vpid == 0 && apid == 0)
|
if(vpid == 0 && apid == 0)
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
dmx = new cDemux(0);
|
dmx = new cDemux(0);
|
||||||
if(!dmx)
|
if(!dmx)
|
||||||
return -1;
|
return ret;
|
||||||
|
#define TS_LEN 188
|
||||||
|
#define TS_BUF_SIZE (TS_LEN * 2048) /* fix dmx buffer size */
|
||||||
|
|
||||||
|
dmxbuf = new unsigned char[TS_BUF_SIZE];
|
||||||
|
if(!dmxbuf){
|
||||||
|
delete dmx;
|
||||||
|
dmx = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
dmx->Open(DMX_TP_CHANNEL, NULL, 3 * 3008 * 62);
|
dmx->Open(DMX_TP_CHANNEL, NULL, 3 * 3008 * 62);
|
||||||
|
|
||||||
if(vpid > 0) {
|
if(vpid > 0) {
|
||||||
@@ -825,8 +831,8 @@ int CStreamInfo2::ts_setup ()
|
|||||||
gettimeofday (&first_tv, NULL);
|
gettimeofday (&first_tv, NULL);
|
||||||
last_tv.tv_sec = first_tv.tv_sec;
|
last_tv.tv_sec = first_tv.tv_sec;
|
||||||
last_tv.tv_usec = first_tv.tv_usec;
|
last_tv.tv_usec = first_tv.tv_usec;
|
||||||
b_total = 0;
|
ret = b_total = 0;
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CStreamInfo2::update_rate ()
|
int CStreamInfo2::update_rate ()
|
||||||
@@ -834,8 +840,6 @@ int CStreamInfo2::update_rate ()
|
|||||||
|
|
||||||
if(!dmx)
|
if(!dmx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unsigned char buf[TS_BUF_SIZE] = {0};
|
|
||||||
long b = 0;
|
long b = 0;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -843,7 +847,7 @@ int CStreamInfo2::update_rate ()
|
|||||||
int timeout = 100;
|
int timeout = 100;
|
||||||
|
|
||||||
|
|
||||||
b_len = dmx->Read(buf, sizeof (buf), timeout);
|
b_len = dmx->Read(dmxbuf, TS_BUF_SIZE, timeout);
|
||||||
//printf("ts: read %d\n", b_len);
|
//printf("ts: read %d\n", b_len);
|
||||||
|
|
||||||
b = b_len;
|
b = b_len;
|
||||||
@@ -881,6 +885,9 @@ int CStreamInfo2::ts_close ()
|
|||||||
if(dmx)
|
if(dmx)
|
||||||
delete dmx;
|
delete dmx;
|
||||||
dmx = NULL;
|
dmx = NULL;
|
||||||
|
if(dmxbuf)
|
||||||
|
delete [] dmxbuf;
|
||||||
|
dmxbuf = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ class CStreamInfo2 : public CMenuTarget
|
|||||||
uint64_t bit_s;
|
uint64_t bit_s;
|
||||||
uint64_t abit_s;
|
uint64_t abit_s;
|
||||||
uint64_t b_total;
|
uint64_t b_total;
|
||||||
|
unsigned char *dmxbuf;
|
||||||
int update_rate();
|
int update_rate();
|
||||||
int ts_setup();
|
int ts_setup();
|
||||||
int ts_close();
|
int ts_close();
|
||||||
|
Reference in New Issue
Block a user