Skip to content

Commit

Permalink
Change: Check for malloc_trim() support. (#668)
Browse files Browse the repository at this point in the history
Add preprocessor directives to check if glibc is used in the system (default in the reference system), since malloc_trim() is not available in other system, like Alpine which uses musl libc
  • Loading branch information
jjnicola authored Mar 14, 2022
1 parent 4bf399b commit e9a94e7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,9 @@ gvm_hosts_deduplicate (gvm_hosts_t *hosts)
hosts->count -= duplicates;
hosts->duplicated += duplicates;
hosts->current = 0;
#ifdef __GLIBC__
malloc_trim (0);
#endif
}

/**
Expand Down Expand Up @@ -1288,7 +1290,9 @@ gvm_hosts_new_with_max (const gchar *hosts_str, unsigned int max_hosts)
gvm_hosts_deduplicate (hosts);

g_strfreev (split);
#ifdef __GLIBC__
malloc_trim (0);
#endif
return hosts;
}

Expand Down

0 comments on commit e9a94e7

Please sign in to comment.