CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Join Date
    Jun 2002
    Posts
    224

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    Hello,

    Why don’t you override the global new operator?
    ZDF

    What is good is twice as good if it's simple.
    "Make it simple" is a complex task.

  2. #17
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    In the other thread he explained that he's doing this in C. My understanding is that he needs the system's heap manager to allocate a specific address range.
    My hobby projects:
    www.rclsoftware.org.uk

  3. #18
    Join Date
    Jun 2002
    Posts
    224

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    Then, why not use #define?
    Code:
    #include <stdlib.h>
    
    void* MyAlloc(size_t)
    {
      void* p;
      // ... 
      return p;
    }
    #define malloc(s) MyAlloc(s)
    
    int main()
    {
      void* p = malloc( 1 ); // MyAlloc will be called instead of stdlib malloc
      return 0;
    }
    ZDF

    What is good is twice as good if it's simple.
    "Make it simple" is a complex task.

  4. #19
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    It's the

    Code:
    // ...
    that we are having a small problem with.

    My hobby projects:
    www.rclsoftware.org.uk

  5. #20
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    As I posted in the other thread...

    Code:
    sometype *ptr = 0x040000;
    If the address is sized, and no other resource is going to try to use it. Not enough information posted (in either thread) to know....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #21
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    Quote Originally Posted by TheCPUWizard
    Not enough information posted (in either thread) to know....
    Yeah, I agree, we don't even know if he is running inside Windows' virtual address space.
    My hobby projects:
    www.rclsoftware.org.uk

  7. #22
    Join Date
    Jun 2002
    Posts
    224

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    Quote Originally Posted by Zaccheus
    It's the

    Code:
    // ...
    that we are having a small problem with.

    So... he needs a memory manager to manage the memory pool?... And this new manager must work better than the original one?
    ZDF

    What is good is twice as good if it's simple.
    "Make it simple" is a complex task.

  8. #23
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Modifying malloc( ) implementation, without changing malloc( ) source code

    I think he wants to allocate memory at a specific address, which is why I suggested VirtualAlloc, but it's really not very clear whether that function is what is needed.
    My hobby projects:
    www.rclsoftware.org.uk

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured