weixin_39743064
2021-01-12 03:56Memory allocation improvements
Hi! I've made some general fixes and improvements to Janus code. The changes were the following:
- wrong usage of getsockname();
- unneeded or redundant use of g_malloc0() and memset() functions, either because they were used together, or the allocated memory is for a struct that has all members set after the allocation, or a memcpy() is done after the allocation;
- unneeded memory allocations checking, as GLib's g_malloc() and others abort the program on failure;
- some unneeded run-time checking of pointers to decide which of g_malloc() and g_realloc() functions should be used - g_realloc(NULL, size) is equivalent to g_malloc(size);
- allocation bug on transports/janus_http.c where calloc() were substituted incorrectly with a g_malloc0();
- a possible memory leak at janus_text2pcap_create();
- an incorrect comment header for janus_plugin_result_destroy(); and
- removed castings from memory allocations.
Please refer to the commits' comments for more details. Thanks!
该提问来源于开源项目:meetecho/janus-gateway
- 点赞
- 回答
- 收藏
- 复制链接分享
8条回答
为你推荐
- 在Go中使用添加前缀的机制是什么?
- append
- memory-management
- slice
- 2个回答
- zlib压缩数据时的内存分配?
- compression
- memory-management
- memory
- zlib
- 1个回答
- 转到存储在动态存储器或静态存储器中的切片
- memory-management
- slice
- 1个回答
- 如何在Go中分配16GB内存?
- ram
- memory-management
- 2个回答
- GoLang-内存分配-[]字节与字符串
- string
- memory
- size
- 1个回答
换一换