2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

ns_os_*memstats() -> ns_main_setmemstats()

This commit is contained in:
Mark Andrews
2001-09-07 00:37:02 +00:00
parent f56cdc894f
commit fe6b7ccc8d
7 changed files with 35 additions and 73 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: main.c,v 1.121 2001/09/07 00:17:25 gson Exp $ */
/* $Id: main.c,v 1.122 2001/09/07 00:36:52 marka Exp $ */
#include <config.h>
@@ -565,10 +565,28 @@ cleanup(void) {
ns_log_shutdown();
}
static char *memstats = NULL;
void
ns_main_setmemstats(const char *filename) {
/*
* Caller has to ensure locking.
*/
if (memstats != NULL) {
free(memstats);
memstats = NULL;
}
if (filename == NULL)
return;
memstats = malloc(strlen(filename) + 1);
if (memstats)
strcpy(memstats, filename);
}
int
main(int argc, char *argv[]) {
isc_result_t result;
static const char *memstats;
result = isc_file_progname(*argv, program_name, sizeof(program_name));
if (result != ISC_R_SUCCESS)
@@ -627,8 +645,7 @@ main(int argc, char *argv[]) {
isc_mem_stats(ns_g_mctx, stdout);
isc_mutex_stats(stdout);
}
memstats = ns_os_getmemstats();
if (memstats) {
if (memstats != NULL) {
FILE *fp = NULL;
result = isc_stdio_open(memstats, "w", &fp);
if (result == ISC_R_SUCCESS) {
@@ -639,6 +656,8 @@ main(int argc, char *argv[]) {
}
isc_mem_destroy(&ns_g_mctx);
ns_main_setmemstats(NULL);
isc_app_finish();
ns_os_shutdown();