From 2fa483e8ba7ec29e99dd81aaccffe7f3e26b556b Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Tue, 1 Sep 1998 00:17:18 +0000 Subject: [PATCH] Added PR_DestroyLogModule. --- nsprpub/pr/include/prlog.h | 5 +++++ nsprpub/pr/src/io/prlog.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/nsprpub/pr/include/prlog.h b/nsprpub/pr/include/prlog.h index ba31361a4cc..9be6c13f104 100644 --- a/nsprpub/pr/include/prlog.h +++ b/nsprpub/pr/include/prlog.h @@ -140,6 +140,11 @@ typedef struct PRLogModuleInfo { */ PR_EXTERN(PRLogModuleInfo*) PR_NewLogModule(const char *name); +/* +** Destroys a log module. +*/ +PR_EXTERN(void) PR_DestroyLogModule(PRLogModuleInfo* logModule); + /* ** Set the file to use for logging. Returns PR_FALSE if the file cannot ** be created diff --git a/nsprpub/pr/src/io/prlog.c b/nsprpub/pr/src/io/prlog.c index 62d79bf4082..98c7e6390d6 100644 --- a/nsprpub/pr/src/io/prlog.c +++ b/nsprpub/pr/src/io/prlog.c @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in @@ -310,6 +310,27 @@ PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char *name) return lm; } +PR_IMPLEMENT(void) PR_DestroyLogModule(PRLogModuleInfo* lm) +{ + PR_LogFlush(); + + /* unlink this log module from the list */ + if (lm == logModules) { + logModules = logModules->next; + } + else { + PRLogModuleInfo* chain = logModules; + while (chain && chain->next != lm) + chain = chain->next; + PR_ASSERT(chain && chain->next); + chain->next = chain->next->next; + } + + /* and free it */ + free((void*)lm->name); + PR_Free(lm); +} + PR_IMPLEMENT(PRBool) PR_SetLogFile(const char *file) { #ifdef PR_LOGGING