Files
mirror-processhacker/trunk/ProcessHacker.Native/Memory/LocalMemoryAlloc.cs
T
flavioe 3d8417f1ea Using the keyboard (Up/Down/Left/Rigth) on TreeViewAdv now works better.
Minor Changes.
NotImplemented methods now are implemented. 

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1420 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-06-14 09:45:24 +00:00

54 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using ProcessHacker.Native.Api;
namespace ProcessHacker.Native
{
/// <summary>
/// Represents a LocalAlloc() memory allocation.
/// </summary>
public class LocalMemoryAlloc : MemoryAlloc
{
public LocalMemoryAlloc(IntPtr memory)
: this(memory, true)
{ }
public LocalMemoryAlloc(IntPtr memory, bool owned)
: base(memory, owned)
{ }
public LocalMemoryAlloc(int size)
: this(size, AllocFlags.LPtr)
{ }
public LocalMemoryAlloc(int size, AllocFlags flags)
{
this.Memory = Win32.LocalAlloc(flags, size);
if (this.Memory == IntPtr.Zero)
throw new OutOfMemoryException();
base.Size = size;
}
protected override void Free()
{
Win32.LocalFree(this);
}
public override void Resize(int newSize)
{
IntPtr newMemory = IntPtr.Zero;
newMemory = Win32.LocalReAlloc(this.Memory, AllocFlags.LMemFixed, newSize);
if (newMemory == IntPtr.Zero)
throw new OutOfMemoryException();
this.Memory = newMemory;
base.Size = newSize;
}
}
}