wbemprox: Add a partial implementation of Win32_NetworkAdapterConfiguration.
[wine.git] / dlls / netapi32 / apibuf.c
bloba88c6f4c31c7ca5ad5a051c9c3c48e9a1262e7e1
1 /*
2 * Copyright 2002 Andriy Palamarchuk
4 * Net API buffer calls
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "lmcons.h"
26 #include "lmapibuf.h"
27 #include "lmerr.h"
28 #include "winerror.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
33 /************************************************************
34 * NetApiBufferAllocate (NETAPI32.@)
36 NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer)
38 TRACE("(%d, %p)\n", ByteCount, Buffer);
40 if (Buffer == NULL) return ERROR_INVALID_PARAMETER;
41 *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount);
42 if (*Buffer)
43 return NERR_Success;
44 else
45 return GetLastError();
48 /************************************************************
49 * NetApiBufferFree (NETAPI32.@)
51 NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
53 TRACE("(%p)\n", Buffer);
54 HeapFree(GetProcessHeap(), 0, Buffer);
55 return NERR_Success;
58 /************************************************************
59 * NetApiBufferReallocate (NETAPI32.@)
61 NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount,
62 LPVOID* NewBuffer)
64 TRACE("(%p, %d, %p)\n", OldBuffer, NewByteCount, NewBuffer);
65 if (NewByteCount)
67 if (OldBuffer)
68 *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
69 else
70 *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount);
71 return *NewBuffer ? NERR_Success : GetLastError();
73 else
75 if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError();
76 *NewBuffer = 0;
77 return NERR_Success;
81 /************************************************************
82 * NetApiBufferSize (NETAPI32.@)
84 NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
86 DWORD dw;
88 TRACE("(%p, %p)\n", Buffer, ByteCount);
89 if (Buffer == NULL)
90 return ERROR_INVALID_PARAMETER;
91 dw = HeapSize(GetProcessHeap(), 0, Buffer);
92 TRACE("size: %d\n", dw);
93 if (dw != 0xFFFFFFFF)
94 *ByteCount = dw;
95 else
96 *ByteCount = 0;
98 return NERR_Success;