Avoid local WINAPI function pointers in _invoke.
[wine] / dlls / netapi32 / apibuf.c
1 /*
2  * Copyright 2002 Andriy Palamarchuk
3  *
4  * Net API buffer calls
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "winbase.h"
22 #include "lmcons.h"
23 #include "lmapibuf.h"
24 #include "lmerr.h"
25 #include "winerror.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
29
30 /************************************************************
31  *                NetApiBufferAllocate  (NETAPI32.@)
32  */
33 NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer)
34 {
35     TRACE("(%ld, %p)\n", ByteCount, Buffer);
36     *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount);
37     if (*Buffer)
38         return NERR_Success;
39     else
40         return GetLastError();
41 }
42
43 /************************************************************
44  *                NetApiBufferFree  (NETAPI32.@)
45  */
46 NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
47 {
48     TRACE("(%p)\n", Buffer);
49     HeapFree(GetProcessHeap(), 0, Buffer);
50     return NERR_Success;
51 }
52
53 /************************************************************
54  *                NetApiBufferReallocate  (NETAPI32.@)
55  */
56 NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount,
57                                              LPVOID* NewBuffer)
58 {
59     TRACE("(%p, %ld, %p)\n", OldBuffer, NewByteCount, NewBuffer);
60     *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
61     if (*NewBuffer)
62         return NERR_Success;
63     else
64         return GetLastError();
65 }
66
67 /************************************************************
68  *                NetApiBufferSize  (NETAPI32.@)
69  */
70 NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
71 {
72     DWORD dw;
73
74     TRACE("(%p, %p)\n", Buffer, ByteCount);
75     if (Buffer == NULL)
76         return ERROR_INVALID_PARAMETER;
77     dw = HeapSize(GetProcessHeap(), 0, Buffer);
78     TRACE("size: %ld\n", dw);
79     if (dw != 0xFFFFFFFF)
80         *ByteCount = dw;
81     else
82         *ByteCount = 0;
83
84     return NERR_Success;
85 }