0

I need to look in source code to understand what internally going on in malloc code when windows application is writing.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
graveman
  • 93
  • 6
  • 1
    Then look in the source code ... this is not a lmgtfy-service .. :o –  Sep 12 '15 at 12:07

2 Answers2

1

As you have indicated that you are looking for mingw-specific implementation, it is easier to realize why you could not find the solution on your own.

Mingw is a "Minimalist GNU for Windows", thus you are probably looking for the GNU libc implementation.

Further reading: How is malloc() implemented internally?

Community
  • 1
  • 1
bessbd
  • 570
  • 4
  • 17
1

Binaries built using the MinGW toolchain make use of the legacy Windows C Runtime, msvcrt.dll. Its implementation of malloc basically just calls HeapAlloc to allocate memory.

To the best of my knowledge, source code for the Win32 heap (HeapAlloc and friends) is not publicly available.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • Ah that's a good hint! Still a question, why do you call it *legacy*? Isn't this still the standard runtime for native win32 applications written in C? –  Sep 12 '15 at 12:58
  • @FelixPalmen: The last version of Visual C++ that targeted msvcrt.dll was Visual C++ 6. Subsequent releases included their own runtime libraries. Visual C++ 2015 and Windows 10 introduce [a new system C runtime.](http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx) – James McNellis Sep 12 '15 at 13:00
  • Oh, thanks for the info! So probably mingw should link against THIS in the future ... –  Sep 12 '15 at 13:01