LWN.net Logo

Zeuthen: Writing a C library, part 1

Zeuthen: Writing a C library, part 1

Posted Jun 29, 2011 11:51 UTC (Wed) by MisterIO (guest, #36192)
In reply to: Zeuthen: Writing a C library, part 1 by elanthis
Parent article: Zeuthen: Writing a C library, part 1

If you have a templated class which can take classes of variable dimensions( i.e. whose dimensions are dinamic at runtime), how would you do that?
You can do that for the nodes structs, but that alone would still be a minimal part of the overall allocations.


(Log in to post comments)

Zeuthen: Writing a C library, part 1

Posted Jun 29, 2011 17:18 UTC (Wed) by cmccabe (guest, #60281) [Link]

Perhaps you could use a memory pool that was freed later.

Zeuthen: Writing a C library, part 1

Posted Jun 29, 2011 19:25 UTC (Wed) by MisterIO (guest, #36192) [Link]

Yeah, I'm not saying that you can't use it in general, but that's a good optimization if you've programmed everything. If the classes that are inserted are someone else's code and they don't use the pool, then suddenly you're gonna have various different memory allocation/deallocation patterns. It could be done, is it always better? I don't know, I consider it an optimization. The suggestion would be to code it in a simple way(which doesn't mean dumb), then profile it and see if/where the bottleneck is and try to solve that and so on. Starting with a complex and optimized design that could be not needed, I'm not sure that's always a good choice.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds