2 * msvcrt.dll heap functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Note: Win32 heap operations are MT safe. We only lock the new
21 * handler and non atomic heap operations
29 #include <internal/mtdll.h>
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
36 #define LOCK_HEAP _mlock( _HEAP_LOCK )
37 #define UNLOCK_HEAP _munlock( _HEAP_LOCK )
40 typedef void (*MSVCRT_new_handler_func
)(unsigned long size
);
42 static MSVCRT_new_handler_func MSVCRT_new_handler
;
43 static int MSVCRT_new_mode
;
46 /*********************************************************************
47 * ??2@YAPAXI@Z (MSVCRT.@)
49 void* MSVCRT_operator_new(unsigned long size
)
51 void *retval
= malloc(size
);
52 TRACE("(%ld) returning %p\n", size
, retval
);
54 if(!retval
&& MSVCRT_new_handler
)
55 (*MSVCRT_new_handler
)(size
);
60 /*********************************************************************
61 * ??3@YAXPAX@Z (MSVCRT.@)
63 void MSVCRT_operator_delete(void *mem
)
70 /*********************************************************************
71 * ?_query_new_handler@@YAP6AHI@ZXZ (MSVCRT.@)
73 MSVCRT_new_handler_func
MSVCRT__query_new_handler(void)
75 return MSVCRT_new_handler
;
79 /*********************************************************************
80 * ?_query_new_mode@@YAHXZ (MSVCRT.@)
82 int MSVCRT__query_new_mode(void)
84 return MSVCRT_new_mode
;
87 /*********************************************************************
88 * ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z (MSVCRT.@)
90 MSVCRT_new_handler_func
MSVCRT__set_new_handler(MSVCRT_new_handler_func func
)
92 MSVCRT_new_handler_func old_handler
;
94 old_handler
= MSVCRT_new_handler
;
95 MSVCRT_new_handler
= func
;
100 /*********************************************************************
101 * ?set_new_handler@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
103 MSVCRT_new_handler_func
MSVCRT_set_new_handler(void *func
)
105 TRACE("(%p)\n",func
);
106 MSVCRT__set_new_handler(NULL
);
110 /*********************************************************************
111 * ?_set_new_mode@@YAHH@Z (MSVCRT.@)
113 int MSVCRT__set_new_mode(int mode
)
117 old_mode
= MSVCRT_new_mode
;
118 MSVCRT_new_mode
= mode
;
123 /*********************************************************************
124 * _heapadd (MSVCRT.@)
126 int _heapadd(void* mem
, size_t size
)
128 TRACE("(%p,%d) unsupported in Win32\n", mem
,size
);