collector.h
00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 00005 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 00006 * Copyright (C) 2003 Apple Computer, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 00024 #ifndef _KJSCOLLECTOR_H_ 00025 #define _KJSCOLLECTOR_H_ 00026 00027 #define KJS_MEM_LIMIT 500000 00028 00029 #include "global.h" 00030 00031 #include <stdio.h> // for size_t 00032 00033 namespace KJS { 00034 00038 class Collector { 00039 // disallow direct construction/destruction 00040 Collector(); 00041 public: 00052 static void* allocate(size_t s); 00057 static bool collect(); 00058 static int size(); 00059 static bool outOfMemory() { return memoryFull; } 00060 00061 #ifdef KJS_DEBUG_MEM 00062 00065 static void finalCheck(); 00066 #endif 00067 00068 private: 00069 static bool memoryFull; 00070 }; 00071 00072 } 00073 00074 #endif /* _KJSCOLLECTOR_H_ */