Remove turn_malloc()
Do not overload malloc() from stdlib.h
This commit is contained in:
parent
ed91d4bc17
commit
fef016901e
@ -824,7 +824,7 @@ char* find_config_file(const char *config_file, int print_file_name)
|
||||
while (config_file_search_dirs[i]) {
|
||||
size_t dirlen = strlen(config_file_search_dirs[i]);
|
||||
size_t fnsz = sizeof(char) * (dirlen + cflen + 10);
|
||||
char *fn = (char*)turn_malloc(fnsz+1);
|
||||
char *fn = (char*)malloc(fnsz+1);
|
||||
strncpy(fn, config_file_search_dirs[i], fnsz);
|
||||
strncpy(fn + dirlen, config_file, fnsz-dirlen);
|
||||
fn[fnsz]=0;
|
||||
@ -842,7 +842,7 @@ char* find_config_file(const char *config_file, int print_file_name)
|
||||
c_execdir && c_execdir[0]) {
|
||||
size_t celen = strlen(c_execdir);
|
||||
fnsz = sizeof(char) * (dirlen + cflen + celen + 10);
|
||||
fn = (char*)turn_malloc(fnsz+1);
|
||||
fn = (char*)malloc(fnsz+1);
|
||||
strncpy(fn,c_execdir,fnsz);
|
||||
size_t fnlen=strlen(fn);
|
||||
if(fnlen<fnsz) {
|
||||
@ -950,7 +950,7 @@ char *base64_encode(const unsigned char *data,
|
||||
|
||||
*output_length = 4 * ((input_length + 2) / 3);
|
||||
|
||||
char *encoded_data = (char*)turn_malloc(*output_length+1);
|
||||
char *encoded_data = (char*)malloc(*output_length+1);
|
||||
if (encoded_data == NULL) return NULL;
|
||||
|
||||
size_t i,j;
|
||||
@ -978,7 +978,7 @@ char *base64_encode(const unsigned char *data,
|
||||
|
||||
void build_base64_decoding_table() {
|
||||
|
||||
decoding_table = (char*)turn_malloc(256);
|
||||
decoding_table = (char*)malloc(256);
|
||||
ns_bzero(decoding_table,256);
|
||||
|
||||
int i;
|
||||
@ -998,7 +998,7 @@ unsigned char *base64_decode(const char *data,
|
||||
if (data[input_length - 1] == '=') (*output_length)--;
|
||||
if (data[input_length - 2] == '=') (*output_length)--;
|
||||
|
||||
unsigned char *decoded_data = (unsigned char*)turn_malloc(*output_length);
|
||||
unsigned char *decoded_data = (unsigned char*)malloc(*output_length);
|
||||
if (decoded_data == NULL) return NULL;
|
||||
|
||||
int i;
|
||||
|
||||
@ -246,7 +246,7 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
|
||||
}
|
||||
|
||||
/* Create container for context and r/w events */
|
||||
e = (struct redisLibeventEvents*)turn_malloc(sizeof(struct redisLibeventEvents));
|
||||
e = (struct redisLibeventEvents*)malloc(sizeof(struct redisLibeventEvents));
|
||||
ns_bzero(e,sizeof(struct redisLibeventEvents));
|
||||
|
||||
e->allocated = 1;
|
||||
|
||||
@ -98,7 +98,7 @@ int turn_mutex_unlock(const turn_mutex *mutex) {
|
||||
int turn_mutex_init(turn_mutex* mutex) {
|
||||
if(mutex) {
|
||||
mutex->data=MAGIC_CODE;
|
||||
mutex->mutex=turn_malloc(sizeof(pthread_mutex_t));
|
||||
mutex->mutex=malloc(sizeof(pthread_mutex_t));
|
||||
pthread_mutex_init((pthread_mutex_t*)mutex->mutex,NULL);
|
||||
return 0;
|
||||
} else {
|
||||
@ -116,7 +116,7 @@ int turn_mutex_init_recursive(turn_mutex* mutex) {
|
||||
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) < 0) {
|
||||
perror("Cannot set type on mutex attr");
|
||||
} else {
|
||||
mutex->mutex = turn_malloc(sizeof(pthread_mutex_t));
|
||||
mutex->mutex = malloc(sizeof(pthread_mutex_t));
|
||||
mutex->data = MAGIC_CODE;
|
||||
if ((ret = pthread_mutex_init((pthread_mutex_t*) mutex->mutex,
|
||||
&attr)) < 0) {
|
||||
@ -787,18 +787,6 @@ void tm_print_func(void) {
|
||||
pthread_mutex_unlock(&tm);
|
||||
}
|
||||
|
||||
extern "C" void *turn_malloc_func(size_t sz, const char* function, int line);
|
||||
void *turn_malloc_func(size_t sz, const char* function, int line) {
|
||||
|
||||
TM_START();
|
||||
|
||||
void *ptr = malloc(sz);
|
||||
|
||||
add_tm_ptr(ptr,id);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line);
|
||||
void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line) {
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ static int udp_create_server_socket(server_type* server,
|
||||
if(!server) return -1;
|
||||
|
||||
evutil_socket_t udp_fd = -1;
|
||||
ioa_addr *server_addr = (ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
||||
ioa_addr *server_addr = (ioa_addr*)malloc(sizeof(ioa_addr));
|
||||
|
||||
STRCPY(server->ifname,ifname);
|
||||
|
||||
@ -102,7 +102,7 @@ static int udp_create_server_socket(server_type* server,
|
||||
|
||||
static server_type* init_server(int verbose, const char* ifname, char **local_addresses, size_t las, int port) {
|
||||
|
||||
server_type* server=(server_type*)turn_malloc(sizeof(server_type));
|
||||
server_type* server=(server_type*)malloc(sizeof(server_type));
|
||||
|
||||
if(!server) return server;
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ static MONGO * get_mongodb_connection(void) {
|
||||
mongoc_init();
|
||||
mongoc_log_set_handler(&mongo_logger, NULL);
|
||||
|
||||
mydbconnection = (MONGO *) turn_malloc(sizeof(MONGO));
|
||||
mydbconnection = (MONGO *) malloc(sizeof(MONGO));
|
||||
mydbconnection->uri = mongoc_uri_new(pud->userdb);
|
||||
|
||||
if (!mydbconnection->uri) {
|
||||
@ -880,7 +880,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
|
||||
bson_init(&doc);
|
||||
|
||||
size_t klen = 9 + strlen(opt);
|
||||
char * _k = (char *)turn_malloc(klen);
|
||||
char * _k = (char *)malloc(klen);
|
||||
strcpy(_k, "options.");
|
||||
strcat(_k, opt);
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ char* decryptPassword(char* in, const unsigned char* mykey){
|
||||
|
||||
|
||||
static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
|
||||
Myconninfo *co = (Myconninfo*)turn_malloc(sizeof(Myconninfo));
|
||||
Myconninfo *co = (Myconninfo*)malloc(sizeof(Myconninfo));
|
||||
ns_bzero(co,sizeof(Myconninfo));
|
||||
if(userdb) {
|
||||
char *s0=turn_strdup(userdb);
|
||||
|
||||
@ -66,7 +66,7 @@ static void RyconninfoFree(Ryconninfo *co) {
|
||||
}
|
||||
|
||||
static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
||||
Ryconninfo *co = (Ryconninfo*) turn_malloc(sizeof(Ryconninfo));
|
||||
Ryconninfo *co = (Ryconninfo*) malloc(sizeof(Ryconninfo));
|
||||
ns_bzero(co,sizeof(Ryconninfo));
|
||||
if (userdb) {
|
||||
char *s0 = turn_strdup(userdb);
|
||||
|
||||
@ -140,7 +140,7 @@ static void fix_user_directory(char *dir0) {
|
||||
}
|
||||
size_t szh = strlen(home);
|
||||
size_t sz = strlen(dir0)+1+szh;
|
||||
char* dir_fixed = (char*)turn_malloc(sz);
|
||||
char* dir_fixed = (char*)malloc(sz);
|
||||
strncpy(dir_fixed,home,szh);
|
||||
strncpy(dir_fixed+szh,dir+1,(sz-szh-1));
|
||||
strncpy(dir0,dir_fixed,sz);
|
||||
|
||||
@ -495,7 +495,7 @@ static int create_new_connected_udp_socket(
|
||||
(char*) (s->e->relay_ifname));
|
||||
}
|
||||
|
||||
ioa_socket_handle ret = (ioa_socket*) turn_malloc(sizeof(ioa_socket));
|
||||
ioa_socket_handle ret = (ioa_socket*) malloc(sizeof(ioa_socket));
|
||||
if (!ret) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
|
||||
"%s: Cannot allocate new socket structure\n", __FUNCTION__);
|
||||
|
||||
@ -250,7 +250,7 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr
|
||||
if(found) {
|
||||
|
||||
size_t j;
|
||||
ioa_addr *new_addrs = (ioa_addr*)turn_malloc(sizeof(ioa_addr)*(list->size-1));
|
||||
ioa_addr *new_addrs = (ioa_addr*)malloc(sizeof(ioa_addr)*(list->size-1));
|
||||
for(j=0;j<i;++j) {
|
||||
addr_cpy(&(new_addrs[j]),&(list->addrs[j]));
|
||||
}
|
||||
@ -336,7 +336,7 @@ static void update_ssl_ctx(evutil_socket_t sock, short events, update_ssl_ctx_cb
|
||||
|
||||
void set_ssl_ctx(ioa_engine_handle e, turn_params_t *params)
|
||||
{
|
||||
update_ssl_ctx_cb_args_t *args = (update_ssl_ctx_cb_args_t *)turn_malloc(sizeof(update_ssl_ctx_cb_args_t));
|
||||
update_ssl_ctx_cb_args_t *args = (update_ssl_ctx_cb_args_t *)malloc(sizeof(update_ssl_ctx_cb_args_t));
|
||||
args->engine = e;
|
||||
args->params = params;
|
||||
args->next = NULL;
|
||||
@ -375,7 +375,7 @@ void add_listener_addr(const char* addr) {
|
||||
turn_params.listener.addrs = (char**)turn_realloc(turn_params.listener.addrs, 0, sizeof(char*)*turn_params.listener.addrs_number);
|
||||
turn_params.listener.addrs[turn_params.listener.addrs_number-1]=turn_strdup(sbaddr);
|
||||
turn_params.listener.encaddrs = (ioa_addr**)turn_realloc(turn_params.listener.encaddrs, 0, sizeof(ioa_addr*)*turn_params.listener.addrs_number);
|
||||
turn_params.listener.encaddrs[turn_params.listener.addrs_number-1]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
||||
turn_params.listener.encaddrs[turn_params.listener.addrs_number-1]=(ioa_addr*)malloc(sizeof(ioa_addr));
|
||||
addr_cpy(turn_params.listener.encaddrs[turn_params.listener.addrs_number-1],&baddr);
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Listener address to use: %s\n",sbaddr);
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
|
||||
stun_buffer_list_elem *ret = get_elem_from_buffer_list(&(e->bufs));
|
||||
|
||||
if(!ret) {
|
||||
ret = (stun_buffer_list_elem *)turn_malloc(sizeof(stun_buffer_list_elem));
|
||||
ret = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
|
||||
ret->buf.len = 0;
|
||||
ret->buf.offset = 0;
|
||||
ret->buf.coffset = 0;
|
||||
@ -312,7 +312,7 @@ static inline void add_elem_to_buffer_list(stun_buffer_list *bufs, stun_buffer_l
|
||||
static void add_buffer_to_buffer_list(stun_buffer_list *bufs, s08bits *buf, size_t len)
|
||||
{
|
||||
if(bufs && buf && (bufs->tsz<MAX_SOCKET_BUFFER_BACKLOG)) {
|
||||
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)turn_malloc(sizeof(stun_buffer_list_elem));
|
||||
stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
|
||||
ns_bcopy(buf,buf_elem->buf.buf,len);
|
||||
buf_elem->buf.len = len;
|
||||
buf_elem->buf.offset = 0;
|
||||
@ -549,7 +549,7 @@ ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_
|
||||
|
||||
if (e && cb && secs > 0) {
|
||||
|
||||
timer_event * te = (timer_event*) turn_malloc(sizeof(timer_event));
|
||||
timer_event * te = (timer_event*) malloc(sizeof(timer_event));
|
||||
int flags = EV_TIMEOUT;
|
||||
if (persist)
|
||||
flags |= EV_PERSIST;
|
||||
@ -903,7 +903,7 @@ ioa_socket_handle create_unbound_relay_ioa_socket(ioa_engine_handle e, int famil
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
|
||||
ret = (ioa_socket*)malloc(sizeof(ioa_socket));
|
||||
ns_bzero(ret,sizeof(ioa_socket));
|
||||
|
||||
ret->magic = SOCKET_MAGIC;
|
||||
@ -1348,7 +1348,7 @@ ioa_socket_handle create_ioa_socket_from_fd(ioa_engine_handle e,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
|
||||
ret = (ioa_socket*)malloc(sizeof(ioa_socket));
|
||||
ns_bzero(ret,sizeof(ioa_socket));
|
||||
|
||||
ret->magic = SOCKET_MAGIC;
|
||||
@ -1613,7 +1613,7 @@ ioa_socket_handle detach_ioa_socket(ioa_socket_handle s)
|
||||
|
||||
ioa_network_buffer_delete(s->e, s->defer_nbh);
|
||||
|
||||
ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
|
||||
ret = (ioa_socket*)malloc(sizeof(ioa_socket));
|
||||
if(!ret) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot allocate new socket structure\n",__FUNCTION__);
|
||||
if(udp_fd>=0)
|
||||
@ -3660,11 +3660,11 @@ static void init_super_memory_region(super_memory_t *r)
|
||||
if(r) {
|
||||
ns_bzero(r,sizeof(super_memory_t));
|
||||
|
||||
r->super_memory = (char**)turn_malloc(sizeof(char*));
|
||||
r->super_memory[0] = (char*)turn_malloc(TURN_SM_SIZE);
|
||||
r->super_memory = (char**)malloc(sizeof(char*));
|
||||
r->super_memory[0] = (char*)malloc(TURN_SM_SIZE);
|
||||
ns_bzero(r->super_memory[0],TURN_SM_SIZE);
|
||||
|
||||
r->sm_allocated = (size_t*)turn_malloc(sizeof(size_t*));
|
||||
r->sm_allocated = (size_t*)malloc(sizeof(size_t*));
|
||||
r->sm_allocated[0] = 0;
|
||||
|
||||
r->sm_total_sz = TURN_SM_SIZE;
|
||||
@ -3684,7 +3684,7 @@ void init_super_memory(void)
|
||||
|
||||
super_memory_t* new_super_memory_region(void)
|
||||
{
|
||||
super_memory_t* r = (super_memory_t*)turn_malloc(sizeof(super_memory_t));
|
||||
super_memory_t* r = (super_memory_t*)malloc(sizeof(super_memory_t));
|
||||
init_super_memory_region(r);
|
||||
return r;
|
||||
}
|
||||
@ -3698,7 +3698,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
||||
void *ret = NULL;
|
||||
|
||||
if(!r) {
|
||||
ret = turn_malloc(size);
|
||||
ret = malloc(size);
|
||||
ns_bzero(ret, size);
|
||||
return ret;
|
||||
}
|
||||
@ -3732,7 +3732,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
||||
if(!region) {
|
||||
r->sm_chunk += 1;
|
||||
r->super_memory = (char**)turn_realloc(r->super_memory,0, (r->sm_chunk+1) * sizeof(char*));
|
||||
r->super_memory[r->sm_chunk] = (char*)turn_malloc(TURN_SM_SIZE);
|
||||
r->super_memory[r->sm_chunk] = (char*)malloc(TURN_SM_SIZE);
|
||||
ns_bzero(r->super_memory[r->sm_chunk],TURN_SM_SIZE);
|
||||
r->sm_allocated = (size_t*)turn_realloc(r->sm_allocated,0,(r->sm_chunk+1) * sizeof(size_t*));
|
||||
r->sm_allocated[r->sm_chunk] = 0;
|
||||
@ -3754,7 +3754,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
||||
pthread_mutex_unlock(&r->mutex_sm);
|
||||
|
||||
if(!ret) {
|
||||
ret = turn_malloc(size);
|
||||
ret = malloc(size);
|
||||
ns_bzero(ret, size);
|
||||
}
|
||||
|
||||
|
||||
@ -935,7 +935,7 @@ static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int
|
||||
|
||||
if(cs && buf0 && cs->ts && cs->bev) {
|
||||
|
||||
char *buf = (char*)turn_malloc(len+1);
|
||||
char *buf = (char*)malloc(len+1);
|
||||
ns_bcopy(buf0,buf,len);
|
||||
buf[len]=0;
|
||||
|
||||
@ -1157,7 +1157,7 @@ static void cliserver_input_handler(struct evconnlistener *l, evutil_socket_t fd
|
||||
|
||||
addr_debug_print(adminserver.verbose, (ioa_addr*)sa,"CLI connected to");
|
||||
|
||||
struct cli_session *clisession = (struct cli_session*)turn_malloc(sizeof(struct cli_session));
|
||||
struct cli_session *clisession = (struct cli_session*)malloc(sizeof(struct cli_session));
|
||||
ns_bzero(clisession,sizeof(struct cli_session));
|
||||
|
||||
clisession->rp = get_realm(NULL);
|
||||
@ -1424,7 +1424,7 @@ void admin_server_receive_message(struct bufferevent *bev, void *ptr)
|
||||
{
|
||||
UNUSED_ARG(ptr);
|
||||
|
||||
struct turn_session_info *tsi = (struct turn_session_info*)turn_malloc(sizeof(struct turn_session_info));
|
||||
struct turn_session_info *tsi = (struct turn_session_info*)malloc(sizeof(struct turn_session_info));
|
||||
turn_session_info_init(tsi);
|
||||
int n = 0;
|
||||
struct evbuffer *input = bufferevent_get_input(bev);
|
||||
@ -1445,7 +1445,7 @@ void admin_server_receive_message(struct bufferevent *bev, void *ptr)
|
||||
|
||||
if(tsi->valid) {
|
||||
ur_map_put(adminserver.sessions, (ur_map_key_type)tsi->id, (ur_map_value_type)tsi);
|
||||
tsi = (struct turn_session_info*)turn_malloc(sizeof(struct turn_session_info));
|
||||
tsi = (struct turn_session_info*)malloc(sizeof(struct turn_session_info));
|
||||
turn_session_info_init(tsi);
|
||||
} else {
|
||||
turn_session_info_clean(tsi);
|
||||
@ -3289,7 +3289,7 @@ static void handle_logon_request(ioa_socket_handle s, struct http_request* hr)
|
||||
|
||||
struct admin_session* as = (struct admin_session*)s->special_session;
|
||||
if(!as) {
|
||||
as = (struct admin_session*)turn_malloc(sizeof(struct admin_session));
|
||||
as = (struct admin_session*)malloc(sizeof(struct admin_session));
|
||||
ns_bzero(as,sizeof(struct admin_session));
|
||||
s->special_session = as;
|
||||
s->special_session_size = sizeof(struct admin_session);
|
||||
|
||||
@ -141,7 +141,7 @@ realm_params_t* get_realm(char* name)
|
||||
unlock_realms();
|
||||
return (realm_params_t*)value;
|
||||
} else {
|
||||
realm_params_t *ret = (realm_params_t*)turn_malloc(sizeof(realm_params_t));
|
||||
realm_params_t *ret = (realm_params_t*)malloc(sizeof(realm_params_t));
|
||||
ns_bcopy(default_realm_params_ptr,ret,sizeof(realm_params_t));
|
||||
STRCPY(ret->options.name,name);
|
||||
value = (ur_string_map_value_type)ret;
|
||||
@ -721,7 +721,7 @@ int add_static_user_account(char *user)
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user account: %s\n",user);
|
||||
} else {
|
||||
size_t ulen = s-user;
|
||||
char *usname = (char*)turn_malloc(sizeof(char)*(ulen+1));
|
||||
char *usname = (char*)malloc(sizeof(char)*(ulen+1));
|
||||
strncpy(usname,user,ulen);
|
||||
usname[ulen]=0;
|
||||
if(SASLprep((u08bits*)usname)<0) {
|
||||
@ -730,7 +730,7 @@ int add_static_user_account(char *user)
|
||||
return -1;
|
||||
}
|
||||
s = skip_blanks(s+1);
|
||||
hmackey_t *key = (hmackey_t*)turn_malloc(sizeof(hmackey_t));
|
||||
hmackey_t *key = (hmackey_t*)malloc(sizeof(hmackey_t));
|
||||
if(strstr(s,"0x")==s) {
|
||||
char *keysource = s + 2;
|
||||
size_t sz = get_hmackey_size(SHATYPE_DEFAULT);
|
||||
@ -1084,10 +1084,10 @@ static ip_range_list_t* ipblacklist = NULL;
|
||||
void init_dynamic_ip_lists(void)
|
||||
{
|
||||
#if !defined(TURN_NO_RWLOCK)
|
||||
whitelist_rwlock = (pthread_rwlock_t*) turn_malloc(sizeof(pthread_rwlock_t));
|
||||
whitelist_rwlock = (pthread_rwlock_t*) malloc(sizeof(pthread_rwlock_t));
|
||||
pthread_rwlock_init(whitelist_rwlock, NULL);
|
||||
|
||||
blacklist_rwlock = (pthread_rwlock_t*) turn_malloc(sizeof(pthread_rwlock_t));
|
||||
blacklist_rwlock = (pthread_rwlock_t*) malloc(sizeof(pthread_rwlock_t));
|
||||
pthread_rwlock_init(blacklist_rwlock, NULL);
|
||||
#else
|
||||
turn_mutex_init(&whitelist_mutex);
|
||||
@ -1163,7 +1163,7 @@ const ip_range_list_t* ioa_get_blacklist(ioa_engine_handle e)
|
||||
|
||||
ip_range_list_t* get_ip_list(const char *kind)
|
||||
{
|
||||
ip_range_list_t *ret = (ip_range_list_t*) turn_malloc(sizeof(ip_range_list_t));
|
||||
ip_range_list_t *ret = (ip_range_list_t*) malloc(sizeof(ip_range_list_t));
|
||||
ns_bzero(ret,sizeof(ip_range_list_t));
|
||||
|
||||
const turn_dbdriver_t * dbd = get_dbdriver();
|
||||
|
||||
@ -1537,7 +1537,7 @@ void tcp_data_connect(app_ur_session *elem, u32bits cid)
|
||||
++elem->pinfo.tcp_conn_number;
|
||||
int i = (int)(elem->pinfo.tcp_conn_number-1);
|
||||
elem->pinfo.tcp_conn=(app_tcp_conn_info**)turn_realloc(elem->pinfo.tcp_conn,0,elem->pinfo.tcp_conn_number*sizeof(app_tcp_conn_info*));
|
||||
elem->pinfo.tcp_conn[i]=(app_tcp_conn_info*)turn_malloc(sizeof(app_tcp_conn_info));
|
||||
elem->pinfo.tcp_conn[i]=(app_tcp_conn_info*)malloc(sizeof(app_tcp_conn_info));
|
||||
ns_bzero(elem->pinfo.tcp_conn[i],sizeof(app_tcp_conn_info));
|
||||
|
||||
elem->pinfo.tcp_conn[i]->tcp_data_fd = clnet_fd;
|
||||
|
||||
@ -125,7 +125,7 @@ static app_ur_session* init_app_session(app_ur_session *ss) {
|
||||
static app_ur_session* create_new_ss(void)
|
||||
{
|
||||
++current_clients_number;
|
||||
return init_app_session((app_ur_session*) turn_malloc(sizeof(app_ur_session)));
|
||||
return init_app_session((app_ur_session*) malloc(sizeof(app_ur_session)));
|
||||
}
|
||||
|
||||
static void uc_delete_session_elem_data(app_ur_session* cdi) {
|
||||
@ -1388,7 +1388,7 @@ void start_mclient(const char *remote_address, int port,
|
||||
++mclient;
|
||||
}
|
||||
|
||||
elems = (app_ur_session**)turn_malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*));
|
||||
elems = (app_ur_session**)malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*));
|
||||
|
||||
__turn_getMSTime();
|
||||
u32bits stime = current_time;
|
||||
|
||||
@ -209,7 +209,7 @@ public:
|
||||
throw WrongStunAttrFormatException();
|
||||
_attr_type = (u16bits)at;
|
||||
_sz = sz;
|
||||
_value=(u08bits*)turn_malloc(_sz);
|
||||
_value=(u08bits*)malloc(_sz);
|
||||
if(ptr)
|
||||
ns_bcopy(ptr,_value,_sz);
|
||||
}
|
||||
@ -239,7 +239,7 @@ public:
|
||||
if(_value)
|
||||
turn_free(_value,_sz);
|
||||
_sz = sz;
|
||||
_value=(u08bits*)turn_malloc(_sz);
|
||||
_value=(u08bits*)malloc(_sz);
|
||||
if(value)
|
||||
ns_bcopy(value,_value,_sz);
|
||||
}
|
||||
@ -569,7 +569,7 @@ public:
|
||||
*/
|
||||
StunMsg() {
|
||||
_allocated_sz = 0xFFFF;
|
||||
_buffer = (u08bits*)turn_malloc(_allocated_sz);
|
||||
_buffer = (u08bits*)malloc(_allocated_sz);
|
||||
_deallocate = true;
|
||||
_sz = 0;
|
||||
_constructed = 0;
|
||||
|
||||
@ -511,8 +511,8 @@ void ioa_addr_add_mapping(ioa_addr *apub, ioa_addr *apriv)
|
||||
size_t new_size = msz + sizeof(ioa_addr*);
|
||||
public_addrs = (ioa_addr**)turn_realloc(public_addrs, msz, new_size);
|
||||
private_addrs = (ioa_addr**)turn_realloc(private_addrs, msz, new_size);
|
||||
public_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
||||
private_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
||||
public_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
|
||||
private_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
|
||||
addr_cpy(public_addrs[mcount],apub);
|
||||
addr_cpy(private_addrs[mcount],apriv);
|
||||
++mcount;
|
||||
|
||||
@ -162,7 +162,7 @@ int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd
|
||||
size_t plen = strlen((s08bits*)upwd);
|
||||
size_t sz = ulen+1+rlen+1+plen+1+10;
|
||||
size_t strl = ulen+1+rlen+1+plen;
|
||||
u08bits *str = (u08bits*)turn_malloc(sz+1);
|
||||
u08bits *str = (u08bits*)malloc(sz+1);
|
||||
|
||||
strncpy((s08bits*)str,(s08bits*)uname,sz);
|
||||
str[ulen]=':';
|
||||
|
||||
@ -118,7 +118,6 @@ static inline u64bits _ioa_ntoh64(u64bits v)
|
||||
#define TURN_LOG_FUNC(level, ...) printf (__VA_ARGS__)
|
||||
|
||||
void tm_print_func(void);
|
||||
void *turn_malloc_func(size_t sz, const char* function, int line);
|
||||
void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line);
|
||||
void turn_free_func(void *ptr, size_t sz, const char* function, int line);
|
||||
void *turn_calloc_func(size_t number, size_t size, const char* function, int line);
|
||||
@ -129,7 +128,6 @@ static inline u64bits _ioa_ntoh64(u64bits v)
|
||||
#define debug_ptr_add(ptr) debug_ptr_add_func((ptr),__FUNCTION__,__LINE__)
|
||||
#define debug_ptr_del(ptr) debug_ptr_del_func((ptr),__FUNCTION__,__LINE__)
|
||||
#define tm_print() tm_print_func()
|
||||
#define turn_malloc(sz) turn_malloc_func((size_t)(sz),__FUNCTION__,__LINE__)
|
||||
#define turn_free(ptr,sz) turn_free_func((ptr),(size_t)(sz),__FUNCTION__,__LINE__)
|
||||
#define turn_realloc(ptr, old_sz, new_sz) turn_realloc_func((ptr),(size_t)(old_sz),(size_t)(new_sz),__FUNCTION__,__LINE__)
|
||||
#define turn_calloc(number, sz) turn_calloc_func((number),(size_t)(sz),__FUNCTION__,__LINE__)
|
||||
@ -142,7 +140,6 @@ static inline u64bits _ioa_ntoh64(u64bits v)
|
||||
#define debug_ptr_add(ptr)
|
||||
#define debug_ptr_del(ptr)
|
||||
#define tm_print()
|
||||
#define turn_malloc(sz) malloc((size_t)(sz))
|
||||
#define turn_free(ptr,sz) free((ptr))
|
||||
#define turn_realloc(ptr, old_sz, new_sz) realloc((ptr),(size_t)(new_sz))
|
||||
#define turn_calloc(number, sz) calloc((number),(size_t)(sz))
|
||||
|
||||
@ -431,7 +431,7 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
|
||||
old_sz_mem, old_sz_mem + sizeof(turn_permission_slot*));
|
||||
slots = parray->extra_slots;
|
||||
parray->extra_sz = old_sz + 1;
|
||||
slots[old_sz] = (turn_permission_slot *)turn_malloc(sizeof(turn_permission_slot));
|
||||
slots[old_sz] = (turn_permission_slot *)malloc(sizeof(turn_permission_slot));
|
||||
slot = slots[old_sz];
|
||||
}
|
||||
}
|
||||
@ -486,7 +486,7 @@ ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn)
|
||||
if(new_chn) {
|
||||
size_t old_sz_mem = old_sz * sizeof(ch_info*);
|
||||
a->extra_chns = (ch_info**)turn_realloc(a->extra_chns,old_sz_mem,old_sz_mem + sizeof(ch_info*));
|
||||
a->extra_chns[old_sz] = (ch_info*)turn_malloc(sizeof(ch_info));
|
||||
a->extra_chns[old_sz] = (ch_info*)malloc(sizeof(ch_info));
|
||||
ns_bzero(a->extra_chns[old_sz],sizeof(ch_info));
|
||||
a->extra_sz += 1;
|
||||
|
||||
@ -574,7 +574,7 @@ tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid
|
||||
}
|
||||
}
|
||||
}
|
||||
tcp_connection *tc = (tcp_connection*)turn_malloc(sizeof(tcp_connection));
|
||||
tcp_connection *tc = (tcp_connection*)malloc(sizeof(tcp_connection));
|
||||
ns_bzero(tc,sizeof(tcp_connection));
|
||||
addr_cpy(&(tc->peer_addr),peer_addr);
|
||||
if(tid)
|
||||
|
||||
@ -168,7 +168,7 @@ static const double __ac_HASH_UPPER = 0.77;
|
||||
if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; \
|
||||
else { \
|
||||
new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(u32bits); \
|
||||
new_flags = (u32bits*)turn_malloc(new_flags_size); \
|
||||
new_flags = (u32bits*)malloc(new_flags_size); \
|
||||
memset(new_flags, 0xaa, new_flags_size); \
|
||||
if (h->n_buckets < new_n_buckets) { \
|
||||
h->keys = (khkey_t*)turn_realloc(h->keys, h->keys_size, new_n_buckets * sizeof(khkey_t)); \
|
||||
|
||||
@ -59,7 +59,7 @@ static int ur_map_init(ur_map* map) {
|
||||
#define ur_map_valid(map) ((map) && ((map)->h) && ((map)->magic==MAGIC_HASH))
|
||||
|
||||
ur_map* ur_map_create() {
|
||||
ur_map *map=(ur_map*)turn_malloc(sizeof(ur_map));
|
||||
ur_map *map=(ur_map*)malloc(sizeof(ur_map));
|
||||
if(ur_map_init(map)<0) {
|
||||
turn_free(map,sizeof(ur_map));
|
||||
return NULL;
|
||||
@ -292,11 +292,11 @@ int lm_map_put(lm_map* map, ur_map_key_type key, ur_map_value_type value)
|
||||
}
|
||||
} else {
|
||||
if(!(*keyp)) {
|
||||
a->extra_keys[i] = (ur_map_key_type*)turn_malloc(sizeof(ur_map_key_type));
|
||||
a->extra_keys[i] = (ur_map_key_type*)malloc(sizeof(ur_map_key_type));
|
||||
keyp = a->extra_keys[i];
|
||||
}
|
||||
if(!(*valuep)) {
|
||||
a->extra_values[i] = (ur_map_value_type*)turn_malloc(sizeof(ur_map_value_type));
|
||||
a->extra_values[i] = (ur_map_value_type*)malloc(sizeof(ur_map_value_type));
|
||||
valuep = a->extra_values[i];
|
||||
}
|
||||
*keyp = key;
|
||||
@ -309,12 +309,12 @@ int lm_map_put(lm_map* map, ur_map_key_type key, ur_map_value_type value)
|
||||
size_t old_sz = esz;
|
||||
size_t old_sz_mem = esz * sizeof(ur_map_key_type*);
|
||||
a->extra_keys = (ur_map_key_type**)turn_realloc(a->extra_keys,old_sz_mem,old_sz_mem + sizeof(ur_map_key_type*));
|
||||
a->extra_keys[old_sz] = (ur_map_key_type*)turn_malloc(sizeof(ur_map_key_type));
|
||||
a->extra_keys[old_sz] = (ur_map_key_type*)malloc(sizeof(ur_map_key_type));
|
||||
*(a->extra_keys[old_sz]) = key;
|
||||
|
||||
old_sz_mem = esz * sizeof(ur_map_value_type*);
|
||||
a->extra_values = (ur_map_value_type**)turn_realloc(a->extra_values,old_sz_mem,old_sz_mem + sizeof(ur_map_value_type*));
|
||||
a->extra_values[old_sz] = (ur_map_value_type*)turn_malloc(sizeof(ur_map_value_type));
|
||||
a->extra_values[old_sz] = (ur_map_value_type*)malloc(sizeof(ur_map_value_type));
|
||||
*(a->extra_values[old_sz]) = value;
|
||||
|
||||
a->extra_sz += 1;
|
||||
@ -979,10 +979,10 @@ static void string_list_free(string_list_header* slh, ur_string_map_func del_val
|
||||
|
||||
static string_list* string_list_add(string_list* sl, const ur_string_map_key_type key, ur_string_map_value_type value) {
|
||||
if(!key) return sl;
|
||||
string_elem *elem=(string_elem*)turn_malloc(sizeof(string_elem));
|
||||
string_elem *elem=(string_elem*)malloc(sizeof(string_elem));
|
||||
elem->list.next=sl;
|
||||
elem->key_size = strlen(key)+1;
|
||||
elem->key=(s08bits*)turn_malloc(elem->key_size);
|
||||
elem->key=(s08bits*)malloc(elem->key_size);
|
||||
ns_bcopy(key,elem->key,elem->key_size);
|
||||
elem->value=value;
|
||||
return &(elem->list);
|
||||
@ -1067,7 +1067,7 @@ static int ur_string_map_valid(const ur_string_map *map) {
|
||||
}
|
||||
|
||||
ur_string_map* ur_string_map_create(ur_string_map_func del_value_func) {
|
||||
ur_string_map *map=(ur_string_map*)turn_malloc(sizeof(ur_string_map));
|
||||
ur_string_map *map=(ur_string_map*)malloc(sizeof(ur_string_map));
|
||||
if(ur_string_map_init(map)<0) {
|
||||
turn_free(map,sizeof(ur_string_map));
|
||||
return NULL;
|
||||
|
||||
@ -177,7 +177,7 @@ static int rtcp_map_init(rtcp_map* map, ioa_engine_handle e) {
|
||||
}
|
||||
|
||||
rtcp_map* rtcp_map_create(ioa_engine_handle e) {
|
||||
rtcp_map *map=(rtcp_map*)turn_malloc(sizeof(rtcp_map));
|
||||
rtcp_map *map=(rtcp_map*)malloc(sizeof(rtcp_map));
|
||||
ns_bzero(map,sizeof(rtcp_map));
|
||||
if(rtcp_map_init(map,e)<0) {
|
||||
turn_free(map,sizeof(rtcp_map));
|
||||
@ -194,7 +194,7 @@ rtcp_map* rtcp_map_create(ioa_engine_handle e) {
|
||||
int rtcp_map_put(rtcp_map* map, rtcp_token_type token, ioa_socket_handle s) {
|
||||
if(!rtcp_map_valid(map)) return -1;
|
||||
else {
|
||||
rtcp_alloc_type *value=(rtcp_alloc_type*)turn_malloc(sizeof(rtcp_alloc_type));
|
||||
rtcp_alloc_type *value=(rtcp_alloc_type*)malloc(sizeof(rtcp_alloc_type));
|
||||
if(!value) return -1;
|
||||
ns_bzero(value,sizeof(rtcp_alloc_type));
|
||||
value->s=s;
|
||||
|
||||
@ -770,7 +770,7 @@ static ts_ur_super_session* create_new_ss(turn_turnserver* server) {
|
||||
//
|
||||
//printf("%s: 111.111: session size=%lu\n",__FUNCTION__,(unsigned long)sizeof(ts_ur_super_session));
|
||||
//
|
||||
ts_ur_super_session *ss = (ts_ur_super_session*)turn_malloc(sizeof(ts_ur_super_session));
|
||||
ts_ur_super_session *ss = (ts_ur_super_session*)malloc(sizeof(ts_ur_super_session));
|
||||
ns_bzero(ss,sizeof(ts_ur_super_session));
|
||||
ss->server = server;
|
||||
get_default_realm_options(&(ss->realm_options));
|
||||
@ -3611,10 +3611,10 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss,
|
||||
int sarlen = stun_attr_get_len(sar);
|
||||
if(sarlen>0) {
|
||||
++norigins;
|
||||
char *o = (char*)turn_malloc(sarlen+1);
|
||||
char *o = (char*)malloc(sarlen+1);
|
||||
ns_bcopy(stun_attr_get_value(sar),o,sarlen);
|
||||
o[sarlen]=0;
|
||||
char *corigin = (char*)turn_malloc(STUN_MAX_ORIGIN_SIZE+1);
|
||||
char *corigin = (char*)malloc(STUN_MAX_ORIGIN_SIZE+1);
|
||||
corigin[0]=0;
|
||||
if(get_canonic_origin(o,corigin,STUN_MAX_ORIGIN_SIZE)<0) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
|
||||
@ -3667,10 +3667,10 @@ static int handle_turn_command(turn_turnserver *server, ts_ur_super_session *ss,
|
||||
if(stun_attr_get_type(sar) == STUN_ATTRIBUTE_ORIGIN) {
|
||||
int sarlen = stun_attr_get_len(sar);
|
||||
if(sarlen>0) {
|
||||
char *o = (char*)turn_malloc(sarlen+1);
|
||||
char *o = (char*)malloc(sarlen+1);
|
||||
ns_bcopy(stun_attr_get_value(sar),o,sarlen);
|
||||
o[sarlen]=0;
|
||||
char *corigin = (char*)turn_malloc(STUN_MAX_ORIGIN_SIZE+1);
|
||||
char *corigin = (char*)malloc(STUN_MAX_ORIGIN_SIZE+1);
|
||||
corigin[0]=0;
|
||||
if(get_canonic_origin(o,corigin,STUN_MAX_ORIGIN_SIZE)<0) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user