Minor memory issues fixed.

'u_long' variable name changed to 'u_dword'. It is not a good idea to name a variable as an existing type.
This commit is contained in:
Jose Angel Gariburo 2017-10-25 17:48:22 +02:00
parent 9d62ea410f
commit c8fb35cf53
4 changed files with 15 additions and 6 deletions

View File

@ -66,7 +66,11 @@ int delay_manager_t::add(my_time_t delay,const dest_t &dest,char *data,int len)
delay_data_t tmp=delay_data; delay_data_t tmp=delay_data;
tmp.data=(char *)malloc(delay_data.len+100); tmp.data=(char *)malloc(delay_data.len+100);
if(!tmp.data)
{
mylog(log_trace, "malloc() returned null in delay_manager_t::add()");
return -1;
}
memcpy(tmp.data,data,delay_data.len); memcpy(tmp.data,data,delay_data.len);
my_time_t tmp_time=get_current_time_us(); my_time_t tmp_time=get_current_time_us();

View File

@ -46,7 +46,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
typedef unsigned long u_long; typedef unsigned long u_dword;
/* /*
* compatibility stuff * compatibility stuff
*/ */
@ -75,7 +75,7 @@ struct timeval {
}; };
#define gettimeofday(x, dummy) { (x)->ticks = clock() ; } #define gettimeofday(x, dummy) { (x)->ticks = clock() ; }
#define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC ) #define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC )
typedef unsigned long u_long ; typedef unsigned long u_dword ;
typedef unsigned short u_short ; typedef unsigned short u_short ;
#else /* typically, unix systems */ #else /* typically, unix systems */
#include <sys/time.h> #include <sys/time.h>
@ -89,12 +89,12 @@ typedef unsigned short u_short ;
t = x.tv_usec + 1000000* (x.tv_sec & 0xff ) ; \ t = x.tv_usec + 1000000* (x.tv_sec & 0xff ) ; \
} }
#define TOCK(t) \ #define TOCK(t) \
{ u_long t1 ; TICK(t1) ; \ { u_dword t1 ; TICK(t1) ; \
if (t1 < t) t = 256000000 + t1 - t ; \ if (t1 < t) t = 256000000 + t1 - t ; \
else t = t1 - t ; \ else t = t1 - t ; \
if (t == 0) t = 1 ;} if (t == 0) t = 1 ;}
u_long ticks[10]; /* vars for timekeeping */ u_dword ticks[10]; /* vars for timekeeping */
#else #else
#define DEB(x) #define DEB(x)
#define DDB(x) #define DDB(x)
@ -640,7 +640,7 @@ init_fec()
#define FEC_MAGIC 0xFECC0DEC #define FEC_MAGIC 0xFECC0DEC
struct fec_parms { struct fec_parms {
u_long magic ; u_dword magic ;
int k, n ; /* parameters of the code */ int k, n ; /* parameters of the code */
gf *enc_matrix ; gf *enc_matrix ;
} ; } ;

View File

@ -51,6 +51,10 @@ void* get_code(int k,int n)
if (table==0) if (table==0)
{ {
table=(void* (*)[256]) malloc(sizeof(void*)*256*256); table=(void* (*)[256]) malloc(sizeof(void*)*256*256);
if(!table)
{
return table;
}
memset(table,0,sizeof(void*)*256*256); memset(table,0,sizeof(void*)*256*256);
} }
if(table[k][n]==0) if(table[k][n]==0)

View File

@ -704,6 +704,7 @@ int client_event_loop()
} }
delay_manager.check(); delay_manager.check();
} }
delete &conn_info;
return 0; return 0;
} }