Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

HeapAlloc/GetProcessHeap PAL support - #849

Merged
jkotas merged 1 commit into
dotnet:masterfrom
tarekgh:HeapAlloc
Feb 11, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
tarekgh:HeapAlloc

Conversation

@tarekgh

@tarekgh tarekgh commented Feb 10, 2016

Copy link
Copy Markdown
Member

No description provided.

@tarekgh

tarekgh commented Feb 10, 2016

Copy link
Copy Markdown
Member Author

CC @jkotas

{
internal unsafe partial class Sys
{
[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemAlloc")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add MemFree here as well (I know it may be unused right now - it is just a point in time thing - any reasonable code that is using MemAlloc needs MemFree as well). And change System.Private.Interop to start use this definition so that we do not have redundant ones.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to add MemReAlloc too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep MemReAlloc separate - it is very rarely used.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if we are going to get S.P.Interop to use it as you suggested then we have to add it. otherwise we'll split the code in S.P.Interop which may be ok too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have separate files:

  • Interop.MemAllocFree.cs - that has malloc and free
  • Interop.MemRealloc.cs - that has realloc

@tarekgh

tarekgh commented Feb 11, 2016

Copy link
Copy Markdown
Member Author

@jkotas I'll do the refactoring for S.P.Interop in different PR as I need to investigate a couple of issues regarding the MCG attributes and also the DLL name we use in the DllImport on Windows as in some cases I am seeing Kernel32 which I think we shouldn't be using

[DllImport(Interop.Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemAlloc")]
internal static extern IntPtr MemAlloc(UIntPtr sizeInBytes);

[DllImport(Libraries.CoreLibNative, EntryPoint = "CoreLibNative_MemFree")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This line has Libraries.CoreLibNative vs. the previous line Interop.Libraries.CoreLibNative. It would be nice to be consistent, at least within one file.

jkotas added a commit that referenced this pull request Feb 11, 2016
HeapAlloc/GetProcessHeap PAL support
@jkotas
jkotas merged commit 53df320 into dotnet:master Feb 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants