// Created on: 2005-03-15
// Created by: Peter KURNEV
-// Copyright (c) 2005-2012 OPEN CASCADE SAS
+// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#include <Standard_MMgrOpt.hxx>
#include <Standard_OutOfMemory.hxx>
#include <Standard_Assert.hxx>
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <stdio.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
-
-#ifndef WNT
-# include <stdlib.h>
-# include <errno.h>
-#endif
-
-#ifdef WNT
-#include <windows.h>
+#ifdef _WIN32
+# include <windows.h>
#else
-# ifdef HAVE_UNISTD_H
-# include <unistd.h>
-# endif
-# ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h> /* mmap() */
-# endif
+# include <sys/mman.h> /* mmap() */
#endif
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+
#include <fcntl.h>
//
#if defined (__sun) || defined(SOLARIS)
#define ROUNDDOWN_CELL(size) ROUNDDOWN8(size)
#define INDEX_CELL(rsize) ((rsize) >> 3)
-// Minimal granularity: 4 bytes (32-bit systems only)
-#ifndef _OCC64
-//#define ROUNDUP_CELL(size) ROUNDUP4(size)
-//#define INDEX_CELL(rsize) ((rsize) >> 2)
-#endif
-
-// Adaptive granularity, less for little blocks and greater for bigger ones:
-/*
-#if _OCC64
-#define ROUNDUP_CELL(size) ((size) <= 0x40 ? ROUNDUP8(size) : ROUNDUP16(size))
-#define INDEX_CELL(rsize) ((rsize) <= 0x40 ? ((rsize) >> 3) : (4 + ((rsize) >> 4)))
-#else
-#define ROUNDUP_CELL(size) ((size) <= 0x40 ? ROUNDUP4(size) : ROUNDUP8(size))
-#define INDEX_CELL(rsize) ((rsize) <= 0x40 ? ((rsize) >> 2) : (8 + ((rsize) >> 3)))
-#endif
-*/
-
-
/* In the allocated block, first bytes are used for storing of memory manager's data.
(size of block). The minimal size of these data is sizeof(int).
The memory allocated in system usually alligned by 16 bytes.Tthe aligment of the
perror("ERR_MEMRY_FAIL");
#endif
-#if defined(IRIX) || defined(__sgi) || defined(SOLARIS) || defined(__sun) || defined(LIN) || defined(linux) || defined(__FreeBSD__)
+#if defined(IRIX) || defined(__sgi) || defined(SOLARIS) || defined(__sun) || defined(LIN) || defined(linux) || defined(__FreeBSD__) || defined(__ANDROID__)
if ((myMMap = open ("/dev/zero", O_RDWR)) < 0) {
if ((myMMap = open ("/dev/null", O_RDWR)) < 0){
myMMap = 0;
//purpose :
//=======================================================================
-void Standard_MMgrOpt::Free(Standard_Address& theStorage)
+void Standard_MMgrOpt::Free(Standard_Address theStorage)
{
// safely return if attempt to free null pointer
if ( ! theStorage )
// otherwise, we have block of big size which shall be simply released
else
FreeMemory (aBlock, RoundSize);
-
- theStorage = NULL;
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address& theStorage,
+Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address theStorage,
const Standard_Size theNewSize)
{
// if theStorage == NULL, just allocate new memory block
if ( myClear )
memset(((char*)newStorage) + OldSize, 0, theNewSize-OldSize);
}
- theStorage = NULL;
return newStorage;
}