* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / mm / memory.c
index 40a0c16ec15a79965654c7ff36d3a3a3c01b20b7..8c685f3d2dbdb41ceb0423e93aaac136efc16c83 100644 (file)
@@ -1,9 +1,9 @@
 /* src/mm/memory.c - 
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Reinhard Grafl
 
    Changes: Christian Thalinger
 
-   $Id: memory.c 3516 2005-10-28 11:37:03Z twisti $
+   $Id: memory.c 4357 2006-01-22 23:33:38Z twisti $
 
 */
 
@@ -93,7 +93,9 @@ static dumpinfo _no_threads_dumpinfo;
 
 #define DEFAULT_CODEMEM_SIZE    128 * 1024  /* defaulting to 128kB            */
 
+#if defined(USE_THREADS)
 static java_objectheader *codememlock = NULL;
+#endif
 static int                codememsize = 0;
 static void              *codememptr  = NULL;
 
@@ -133,8 +135,7 @@ static void *memory_checked_alloc(s4 size)
        void *p = calloc(size, 1);
 
        if (!p)
-               throw_cacao_exception_exit(string_java_lang_InternalError,
-                                                                  "Out of memory");
+               exceptions_throw_outofmemory_exit();
 
        return p;
 }
@@ -179,7 +180,7 @@ void *memory_cnew(s4 size)
                if ((p = memory_checked_alloc(codememsize + pagesize - 1)) == NULL)
                        return NULL;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                if (opt_stat) {
                        codememusage += codememsize + pagesize - 1;
 
@@ -223,7 +224,7 @@ void *mem_alloc(s4 size)
        if (size == 0)
                return NULL;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        if (opt_stat) {
                memoryusage += size;
 
@@ -247,7 +248,7 @@ void *mem_realloc(void *src, s4 len1, s4 len2)
                }
        }
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        if (opt_stat)
                memoryusage = (memoryusage - len1) + len2;
 #endif
@@ -255,8 +256,7 @@ void *mem_realloc(void *src, s4 len1, s4 len2)
        dst = realloc(src, len2);
 
        if (!dst)
-               throw_cacao_exception_exit(string_java_lang_InternalError,
-                                                                  "Out of memory");
+               exceptions_throw_outofmemory_exit();
 
        return dst;
 }
@@ -272,7 +272,7 @@ void mem_free(void *m, s4 size)
                assert(0);
        }
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        if (opt_stat)
                memoryusage -= size;
 #endif
@@ -342,7 +342,7 @@ void *dump_alloc(s4 size)
 
                di->allocateddumpsize += newdumpblocksize;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                /* the amount of globally allocated dump memory (thread save) */
 
                if (opt_stat)
@@ -360,7 +360,7 @@ void *dump_alloc(s4 size)
 
        di->useddumpsize += size;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        if (opt_stat)
                if (di->useddumpsize > maxdumpsize)
                        maxdumpsize = di->useddumpsize;
@@ -438,7 +438,7 @@ void dump_release(s4 size)
                di->allocateddumpsize -= tmp->size;
                di->currentdumpblock = tmp->prev;
 
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
                /* the amount of globally allocated dump memory (thread save) */
 
                if (opt_stat)