mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / src / common / portlib / NdbMem.c
blob74f667e9c44d9fb920f999b6a93b2756eb02fdd8
1 /* Copyright (c) 2003-2005, 2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
17 #include <ndb_global.h>
19 #include <NdbMem.h>
21 void NdbMem_Create()
23 /* Do nothing */
24 return;
27 void NdbMem_Destroy()
29 /* Do nothing */
30 return;
34 void* NdbMem_Allocate(size_t size)
36 void* mem_allocated;
37 assert(size > 0);
38 mem_allocated= (void*)malloc(size);
39 return mem_allocated;
42 void* NdbMem_AllocateAlign(size_t size, size_t alignment)
44 (void)alignment; /* remove warning for unused parameter */
46 return (void*)memalign(alignment, size);
47 TEMP fix
49 return (void*)malloc(size);
53 void NdbMem_Free(void* ptr)
55 free(ptr);
59 int NdbMem_MemLockAll(int i){
60 if (i == 1)
62 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined (MCL_FUTURE)
63 return mlockall(MCL_CURRENT | MCL_FUTURE);
64 #else
65 return -1;
66 #endif
68 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
69 return mlockall(MCL_CURRENT);
70 #else
71 return -1;
72 #endif
75 int NdbMem_MemUnlockAll(){
76 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
77 return munlockall();
78 #else
79 return -1;
80 #endif