Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

allocator

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my Bulk Allocator function how can I returns a pointer to a contiguous block of memory of at least size bytes, similar to malloc()

extra 8 bytes will be given to a header for our bulk allocated objects in the same fashion as pool allocated objects thus being freed easily

bulk_alloc() function returns a pointer to a contiguous block of memory similar to malloc().
 
Saloon Keeper
Posts: 12128
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uhh how about just this:
 
Ranch Hand
Posts: 184
4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering if the 'header' is hidden from the caller? Ie. in the same way that the memory returned by malloc() at address X probably starts at X-N where N is the size of the 'header' containing information for use by the system. In which case the appropriate code (which I'm assuming should be C) might be:
But I'm guessing.
 
No more fooling around. Read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic