ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

apibuf.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2002 Andriy Palamarchuk
00003  *
00004  * Net API buffer calls
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdarg.h>
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "lmcons.h"
00026 #include "lmapibuf.h"
00027 #include "lmerr.h"
00028 #include "winerror.h"
00029 #include "wine/debug.h"
00030 
00031 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
00032 
00033 /************************************************************
00034  *                NetApiBufferAllocate  (NETAPI32.@)
00035  */
00036 NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID* Buffer)
00037 {
00038     TRACE("(%d, %p)\n", ByteCount, Buffer);
00039 
00040     if (Buffer == NULL) return ERROR_INVALID_PARAMETER;
00041     *Buffer = HeapAlloc(GetProcessHeap(), 0, ByteCount);
00042     if (*Buffer)
00043         return NERR_Success;
00044     else
00045         return GetLastError();
00046 }
00047 
00048 /************************************************************
00049  *                NetApiBufferFree  (NETAPI32.@)
00050  */
00051 NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
00052 {
00053     TRACE("(%p)\n", Buffer);
00054     HeapFree(GetProcessHeap(), 0, Buffer);
00055     return NERR_Success;
00056 }
00057 
00058 /************************************************************
00059  *                NetApiBufferReallocate  (NETAPI32.@)
00060  */
00061 NET_API_STATUS WINAPI NetApiBufferReallocate(LPVOID OldBuffer, DWORD NewByteCount,
00062                                              LPVOID* NewBuffer)
00063 {
00064     TRACE("(%p, %d, %p)\n", OldBuffer, NewByteCount, NewBuffer);
00065     if (NewByteCount) 
00066     {
00067         if (OldBuffer)
00068             *NewBuffer = HeapReAlloc(GetProcessHeap(), 0, OldBuffer, NewByteCount);
00069         else
00070             *NewBuffer = HeapAlloc(GetProcessHeap(), 0, NewByteCount);
00071     return *NewBuffer ? NERR_Success : GetLastError();
00072     } 
00073     else 
00074     {
00075     if (!HeapFree(GetProcessHeap(), 0, OldBuffer)) return GetLastError();
00076     *NewBuffer = 0;
00077     return NERR_Success;
00078     }
00079 }
00080 
00081 /************************************************************
00082  *                NetApiBufferSize  (NETAPI32.@)
00083  */
00084 NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount)
00085 {
00086     DWORD dw;
00087 
00088     TRACE("(%p, %p)\n", Buffer, ByteCount);
00089     if (Buffer == NULL)
00090         return ERROR_INVALID_PARAMETER;
00091     dw = HeapSize(GetProcessHeap(), 0, Buffer);
00092     TRACE("size: %d\n", dw);
00093     if (dw != 0xFFFFFFFF)
00094         *ByteCount = dw;
00095     else
00096         *ByteCount = 0;
00097 
00098     return NERR_Success;
00099 }

Generated on Mon May 28 2012 04:25:00 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.