[stsf-commit] stsf/stsflib datamgr.c, 1.2, 1.3 fscomm.c, 1.5, 1.6 stsfutil.c, 1.11, 1.12

Alexander Gelfenbain stsf-commit at pdx.freedesktop.org
Fri Jun 4 22:23:07 PDT 2004


Committed by: adg


Index: datamgr.c
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/datamgr.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/datamgr.c	22 Apr 2004 20:56:32 -0000	1.2
+++ b/datamgr.c	5 Jun 2004 05:23:04 -0000	1.3
@@ -313,23 +313,25 @@
     OpaqueDataManager *p = (OpaqueDataManager *) g;
     int i;
 
-    fprintf(DebugFile, "OpaqueDataManager: <buckets: %d, elements: %d>\n", p->nbuckets, p->count);
+    DebugStr(-1, "OpaqueDataManager: <buckets: %d, elements: %d>\n", p->nbuckets, p->count);
     for (i=0; i<p->nbuckets; i++) {
-        fprintf(DebugFile, "%d ", listCount(p->buckets[i]));
+        DebugStr(-1, "%d ", listCount(p->buckets[i]));
     }
-    fprintf(DebugFile, "\n");
+    DebugStr(-1, "\n");
 
     if (printRefCnt) {
         for (i=0; i<p->nbuckets; i++) {
             int count = listCount(p->buckets[i]);
-            fprintf(DebugFile, "#%d -> %d: [", i, count);
+            DebugStr(-1, "#%d -> %d: [", i, count);
             if (count > 0) {
                 listToFirst(p->buckets[i]);
                 do {
-                    fprintf(DebugFile, "%d ", ((Node *)listCurrent(p->buckets[i]))->refCnt);
+                    Node *n = (Node *) listCurrent(p->buckets[i]);
+
+                    DebugStr(-1, "(%08X %08X => %08X, refCnt: %d)", n->key1, n->key2, n->ptr, n->refCnt);
                 } while (listNext(p->buckets[i]));
             }
-            fprintf(DebugFile,"]\n");
+            DebugStr(-1,"]\n");
         }
     }
 }

Index: fscomm.c
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/fscomm.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/fscomm.c	30 May 2004 23:07:18 -0000	1.5
+++ b/fscomm.c	5 Jun 2004 05:23:04 -0000	1.6
@@ -1846,7 +1846,7 @@
                       uint64_t cid,
                       STCount streamcount,
                       uint32_t *streamsizes,
-                      size_t totalsize)
+                      uint32_t totalsize)
 {
     fsc_createfonts_in *q = (fsc_createfonts_in *) p;
     uint32_t curoffs = sizeof(fsc_createfonts_in);

Index: stsfutil.c
===================================================================
RCS file: /cvs/stsf/stsf/stsflib/stsfutil.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- a/stsfutil.c	30 May 2004 23:07:18 -0000	1.11
+++ b/stsfutil.c	5 Jun 2004 05:23:04 -0000	1.12
@@ -275,6 +275,7 @@
 }
         
         
+#define LOADFILE_DEBUGLEVEL 0
 
 FileImage *LoadFile(const char *fname, off_t minsize, off_t maxsize)
 {
@@ -285,21 +286,33 @@
     byte *p;
     int sizecheck = TRUE;
 
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "%s: fname: [%d] ", __func__, fname);
+    }
+#endif
+
     if (fd == -1) {
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "open: %s.\n", strerror(errno));
+    }
+#endif
         return NULL;
     }
 
     if (fstat(fd, &st) == -1) {
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "fstat: %s.\n", strerror(errno));
+    }
+#endif
         close(fd);
         return NULL;
     }
 
     fsize = st.st_size;
-#if 0
-    // 1. I doubt there are any fonts less than 1024 bytes.
-    // 2. Don't load any fonts larger than 100M - they look suspicious anyway
-    // if (fsize < 1024 || fsize > 104857600) {
-#endif
+
     if (minsize != -1) {
         if (fsize < minsize) {
             sizecheck = FALSE;
@@ -313,26 +326,33 @@
     }
         
     if (!sizecheck) {
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "\n");
+    }
+#endif
         DebugStr(1, "%s: LoadFile rejected the file due to its size (%d).", fname, fsize);
         close(fd);
         return NULL;
     }
-/* XXX need to figure out how to do it on Windows */
-#ifdef _WIN32
-#else
+
     p = (byte *) mmap(0, fsize, PROT_READ, MAP_SHARED, fd, 0);
+
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "fsize: %d, mapped to: %08X\n", fsize, p);
+    }
 #endif
+
     close(fd);
     if (p == MAP_FAILED) {
         return NULL;
     }
 
     if ((f = malloc(sizeof(FileImage))) == NULL) {
-#ifdef _WIN32
-#else
+        ErrorStr("malloc() failed, calling munmap.");
+        
         munmap((void *)p, fsize);
-#endif
-        /* munmap(p, fsize); */
         return NULL;
     }
 
@@ -347,13 +367,16 @@
 
 void UnloadFile(FileImage *f)
 {
-#ifdef _WIN32
-#else
-    munmap((void *)f->ptr, f->len);
+#ifdef STSF_DEBUG
+    if (DebugLevel > LOADFILE_DEBUGLEVEL) {
+        DebugStr(-1, "%s: ptr: %08X, len: %d\n", f->ptr, f->len);
+    }
 #endif
+    munmap((void *)f->ptr, f->len);
     free(f->fname);
     free(f);
 }
+#undef LOAFILE_DEBUGLEVEL
 
 /*
  * Calculates the 128-bit checksum of a memory area




More information about the stsf-commit mailing list