Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated/incorrect documentation for use of containers with fixed allocators #484

Open
Woazboat opened this issue Sep 2, 2022 · 1 comment

Comments

@Woazboat
Copy link

Woazboat commented Sep 2, 2022

When using a standard non-fixed container (e.g. list, map, etc...) with a fixed allocator like eastl::fixed_pool or eastl::fixed_node_allocator, the default container constructor (/the default parameter for the allocator) attempts to construct the allocator using the container name string as the first parameter.

e.g. for map:

// Constructor
map(const allocator_type& allocator = EASTL_MAP_DEFAULT_ALLOCATOR);
// i.e. 
map(const allocator_type& allocator = allocator_type("EASTL map"));

The fixed allocator constructors are declared as:

explicit fixed_pool(void* pMemory = NULL);
fixed_node_allocator(void* pNodeBuffer);

This breaks and fails to compile when a fixed allocator is used for a default constructed container since the fixed allocators do not use the name as the first constructor parameter. (Actually it attempts to use the const char* string as the void* memory buffer argument and the only reason it fails to compile is because it expects a non-const pointer, otherwise it would silently accept it which might be even worse.)

The example that's given in the documentation does not actually work due to this issue.
https://eastl.docsforge.com/master/faq/#cont10-how-do-i-use-a-memory-pool-with-a-container

char buffer[256];

list<Widget, fixed_pool> myList;
myList.get_allocator().init(buffer, 256);
@Woazboat
Copy link
Author

Woazboat commented Sep 2, 2022

Okay, seems like this is more of an issue with (outdated?) documentation. eastl::fixed_allocator takes a name string as the first argument and therefore works properly. eastl::fixed_pool and eastl::fixed_node_allocator are in the internal folder, so I guess they don't need to conform to the convention.

The documentation here should be changed to use eastl::fixed_allocator instead of eastl::fixed_pool.

@Woazboat Woazboat changed the title Cannot default construct (non-fixed) containers with fixed allocators Outdated/incorrect documentation for use of containers with fixed allocators Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant