Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6860435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:24:30+00:00 2026-05-27T02:24:30+00:00

I have the source for a large (>250 files) library that makes heavy use

  • 0

I have the source for a large (>250 files) library that makes heavy use of STL containers and strings. I need to run it in an embedded environment with limited heap, so I want to ensure that this library itself is limited in its heap usage.

The obvious solution is to create an allocator, but modifying the entire code base to include the allocator template parameter is a big job of last resort, and undesirable in case I ever want to take a new version of the source. Globally replacing new and delete is not feasible since that affects the entire image, not just this library.

My next thought was a stupid C macro trick, but that doesn’t seem like it would be possible, although I admit to not being a clever macro author.

So I thought “is there a compiler or pragma switch to specify the allocator<> class at compile time”? But I’m open for anything.

The next question I’ll ask, if anyone can come up with a solution, is how to do the same for new/delete within the set of files comprising this library.

I’m using the gcc 3.4.4 toolchain to run this under Cygwin, with a target of VxWorks, if that sparks any ideas.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:24:31+00:00Added an answer on May 27, 2026 at 2:24 am

    I resorted to the preprocessor to get a possible solution, although it currently relies upon the GCC 3.4.4 implementation to work.

    The GCC <memory> implementation includes the file <bits/allocator.h>, which in turn includes another file <bits/c++allocator.h>, which defines a macro that defines the class implementing the default allocator base class.

    Since is found in a platform-dependent path (/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/i686-pc-cygwin/bits), I don’t feel (very) dirty in supplanting it with my own “platform-dependent” implementation.

    So I just create a folder bits/ in the root of my source’s include path, and then create the file c++allocator.h in that folder. I define the required macro to be the name of my allocator class and it works like a charm, since gcc searches my include paths prior to searching the system includes.

    Thanks for all your responses. I think I can go with this “solution”, which will only work as long as I’m using 3.4.4 probably.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather large open source class that I need to convert from
I have inherited a project that has a large number of source files. I
I have a large source file in Perforce that has been split up into
I'd like to find a few large .NET projects that have public source code
I have this method that changes an larger image source on click. I need
I have a large acceptance test suite that runs the source application many thousands
I have many large files under project/public/deploy/. All the rest is my source codes.
A bit context. Let's say I have source files, which need to end up
I have an open source library which is designed to support very large collections
I have a large source repository split across multiple projects. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.