Skip to content

Commit

Permalink
pike: use pkg_malloc/pkg_free instead of system malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
henningw committed Mar 29, 2023
1 parent fb1f01c commit 6492a6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/pike/pike_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ int pike_top_add_entry( unsigned char *ip_addr, int addr_len,
unsigned int expires, pike_node_status_t status )
{
struct TopListItem_t *new_item
= (struct TopListItem_t *)malloc(sizeof(struct TopListItem_t));
= (struct TopListItem_t *)pkg_malloc(sizeof(struct TopListItem_t));
if(!new_item)
{
SYS_MEM_ERROR;
PKG_MEM_ERROR;
return -1;
}
print_addr(ip_addr, addr_len);
Expand Down Expand Up @@ -119,7 +119,7 @@ void pike_top_list_clear()
top_list_iter = top_list_root;
while (top_list_iter) {
ptr = top_list_iter->next;
free(top_list_iter);
pkg_free(top_list_iter);
top_list_iter = ptr;
}
top_list_root = 0;
Expand Down

2 comments on commit 6492a6f

@miconda
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this has to reverted, several rpc commands use system malloc on purpose if they might be returning a lot of data. Otherwise they will fail and allocating a lot of pkg at startup just for punctual needs of rpc commands is not recommended.

So, do not blindly replace system malloc/free with pkg variants if it is about rpc. jsonrpcs also uses system malloc, ctl as well, iirc ...

@kamailio-sync
Copy link

@kamailio-sync kamailio-sync commented on 6492a6f Mar 29, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.