Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / netapi32 / apibuf.c
blob6a8b8db1bdedbb320d34874c6fbed3cf1562686b
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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("(%ld, %p)\n", ByteCount, Buffer);
39 *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount);
40 if (*Buffer)
41 return NERR_Success;
42 else
43 return GetLastError();
46 /************************************************************
47 * NetApiBufferFree (NETAPI32.@)
49 NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
51 TRACE("(%p)\n", Buffer);
52 HeapFree(GetProcessHeap(), 0, Buffer);
53 return NERR_Success;
56 /************************************************************
57 * NetApiBufferReallocate (NETAPI32.@)
59 NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount,
60 LPVOID* NewBuffer)
62 TRACE("(%p, %ld, %p)\n", OldBuffer, NewByteCount, NewBuffer);
63 if (NewByteCount)
65 if (OldBuffer)
66 *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
67 else
68 *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount);
69 return *NewBuffer ? NERR_Success : GetLastError();
71 else
73 if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError();
74 *NewBuffer = 0;
75 return NERR_Success;
79 /************************************************************
80 * NetApiBufferSize (NETAPI32.@)
82 NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
84 DWORD dw;
86 TRACE("(%p, %p)\n", Buffer, ByteCount);
87 if (Buffer == NULL)
88 return ERROR_INVALID_PARAMETER;
89 dw = HeapSize(GetProcessHeap(), 0, Buffer);
90 TRACE("size: %ld\n", dw);
91 if (dw != 0xFFFFFFFF)
92 *ByteCount = dw;
93 else
94 *ByteCount = 0;
96 return NERR_Success;