Added PR_DestroyLogModule.
authorwarren%netscape.com
Tue, 01 Sep 1998 00:17:18 +0000
changeset 225 5b0e0a12c524d0d4521953cdd47fcf2b84410ac9
parent 224 5b8c5134fb3b5dabe238d44831390220161ebb9f
child 226 1863c4da1d78b4428e445c88b802dd1af3c05c56
push idunknown
push userunknown
push dateunknown
Added PR_DestroyLogModule.
pr/include/prlog.h
pr/src/io/prlog.c
--- a/pr/include/prlog.h
+++ b/pr/include/prlog.h
@@ -136,16 +136,21 @@ typedef struct PRLogModuleInfo {
 } PRLogModuleInfo;
 
 /*
 ** Create a new log module.
 */
 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
 */
 PR_EXTERN(PRBool) PR_SetLogFile(const char *name);
 
 /*
 ** Set the size of the logging buffer. If "buffer_size" is zero then the
 ** logging becomes "synchronous" (or unbuffered).
--- a/pr/src/io/prlog.c
+++ b/pr/src/io/prlog.c
@@ -1,9 +1,9 @@
-/* -*- 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
  * compliance with the NPL.  You may obtain a copy of the NPL at
  * http://www.mozilla.org/NPL/
  * 
  * Software distributed under the NPL is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
@@ -305,16 +305,37 @@ PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLog
         lm->level = PR_LOG_NONE;
         lm->next = logModules;
         logModules = lm;
     }
     _PR_SetLogModuleLevel(lm);
     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
 #ifdef _PR_USE_STDIO_FOR_LOGGING
     FILE *newLogFile;
 
     newLogFile = fopen(file, "w");
     if (newLogFile) {