ReactOS 0.4.15-dev-7788-g1ad9096
apibuf.c
Go to the documentation of this file.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "netapi32.h"
22
24
25/************************************************************
26 * NetApiBufferAllocate (NETAPI32.@)
27 */
29{
30 TRACE("(%d, %p)\n", ByteCount, Buffer);
31
32 if (Buffer == NULL) return ERROR_INVALID_PARAMETER;
34 if (*Buffer)
35 return NERR_Success;
36 else
37 return GetLastError();
38}
39
40/************************************************************
41 * NetApiBufferFree (NETAPI32.@)
42 */
44{
45 TRACE("(%p)\n", Buffer);
47 return NERR_Success;
48}
49
50/************************************************************
51 * NetApiBufferReallocate (NETAPI32.@)
52 */
54 LPVOID* NewBuffer)
55{
56 TRACE("(%p, %d, %p)\n", OldBuffer, NewByteCount, NewBuffer);
57 if (NewByteCount)
58 {
59 if (OldBuffer)
60 *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
61 else
62 *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount);
63 return *NewBuffer ? NERR_Success : GetLastError();
64 }
65 else
66 {
67 if (!HeapFree(GetProcessHeap(), 0, OldBuffer))
68 return GetLastError();
69 *NewBuffer = 0;
70 return NERR_Success;
71 }
72}
73
74/************************************************************
75 * NetApiBufferSize (NETAPI32.@)
76 */
78{
79 DWORD dw;
80
81 TRACE("(%p, %p)\n", Buffer, ByteCount);
82 if (Buffer == NULL)
85 TRACE("size: %d\n", dw);
86 if (dw != 0xFFFFFFFF)
87 *ByteCount = dw;
88 else
89 *ByteCount = 0;
90
91 return NERR_Success;
92}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
Definition: apibuf.c:77
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount, LPVOID *NewBuffer)
Definition: apibuf.c:53
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define NERR_Success
Definition: lmerr.h:5
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t * LPDWORD
Definition: typedefs.h:59
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1099