About 13 years ago, when the C language was rare in Bulgaria and everybody was writing in Turbo Pascal :) a colleague founded a "C club" and started to program enthusiastically in C. That was the time I, a "hard core" Assemblist, started learning C too ;-) He wrote some rather complex projects and of course, his own memory manager! I still remember how he sometimes was wondering "Someone eats my memory!". This was many months on end before he found the bug and fixed it. Memory leakage is a typical symptom for all memory managers, even Tom's tiny but great in value TALLOC.C! These days, another colleague of mine found a bug in it causing the dreaded memory leakage when repeatedly freeing and allocating a block. The bug was in malloc() and the second patch below fixes it. I've uploaded my CVSPATCH.TXT at its "duty" place (http://linux.tu-varna.acad.bg/~lig/freedos/CVSPATCH.TXT). Since it's small yet, here it is, included in its entirety.

Lucho

diff -ruN cvs/kernel/kernel/dosnames.c src/kernel/kernel/dosnames.c
--- cvs/kernel/kernel/dosnames.c2004-03-07 14:59:38.000000000 +0200
+++ src/kernel/kernel/dosnames.c2004-03-13 12:07:20.000000000 +0200
@@ -107,18 +107,7 @@
   }

if (nFileCnt == 0)
- {
-/* Lixing Yuan Patch */
- if (bAllowWildcards) /* for find first */
- {
- if (*filename != '\0')
- return DE_FILENOTFND;
- memset(fcbname, '?', FNAME_SIZE + FEXT_SIZE);
- return nDirCnt;
- }
- else
- return DE_FILENOTFND;
- }
+ return bAllowWildcards && *filename == '\0' ? DE_NFILES : DE_PATHNOTFND;


   /* Now we have pointers set to the directory portion and the    */
   /* file portion.  Now determine the existance of an extension.  */
diff -ruN cvs/kernel/sys/talloc.c src/kernel/sys/talloc.c
--- cvs/kernel/sys/talloc.c2004-02-07 19:59:44.000000000 +0200
+++ src/kernel/sys/talloc.c2004-03-12 15:54:14.000000000 +0200
@@ -83,11 +83,11 @@
     }
     dbprintf(("follow [%x] = %x\n",akt, akt->length));
     next = (block *)(&akt->data[akt->length & ~BUSY]);
-    if (next == ltop || isbusy(akt))
+    if (isbusy(akt))
     {
       akt = next; /* next block */
     }
-    else if (isbusy(next))
+    else if (next == ltop || isbusy(next))
     {
       size_t size = akt->length;
       if (size >= length) /* try to split */


------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Freedos-kernel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freedos-kernel

Reply via email to