0

Whenever I try to create an object(queue, thread, or byte pool) I can only create them by doing dynamic memory allocation; it fails if I try a static memory allocation.

I am unable to find the txm_module_object_allocate API anywhere in the documentation.

//Works:
TX_BYTE_POOL* my_byte_pool=NULL;
txm_module_object_allocate(&my_byte_pool, sizeof(TX_BYTE_POOL));
tx_byte_pool_create(my_byte_pool, "Task Pool", free_memory_task, 16*1240);

//Fails:
TX_BYTE_POOL my_byte_pool;
tx_byte_pool_create(&my_byte_pool, "Task Pool", free_memory_task, 16*1240);

In the second case, I always get the error that tx_byte_pool_create failed.

ish kool
  • 1
  • 1
  • 3
    What is the first argument to `tx_byte_pool_create` supposed to be? In the "working" case you pass something of type `TX_BYTE_POOL*` while in the "failing" case you pass something of type `TX_BYTE_POOL`. Should it be a pointer to `TX_BYTE_POOL` or not? And doesn't the compiler complain when you pass the wrong type? – Some programmer dude Oct 01 '19 at 06:51
  • I have corrected and shortened both the title and the body text (deleted what was essentially a repetition) of this question, in order to hopefully strengthen its impact. – Adrian Mole Oct 01 '19 at 08:05
  • `txm_module_object_allocate` or `tx_module_object_allocate`? – KamilCuk Oct 01 '19 at 08:23
  • Thanks for pointing it out it's txm_module_object_allocate. – ish kool Oct 02 '19 at 08:30
  • @Someprogrammerdude Thanks for pointing out the typo, I have edited the question. Hence, `tx_byte_pool_create` accepts a pointer to `TX_BYTE_POOL`. – ish kool Oct 02 '19 at 09:57

1 Answers1

0

Yes, txm_module_object_allocate expects the first argument to be a pointer of type TX_BYTE_POOL . So the correct syntax or the function to be called is txm_module_object_allocate(&my_byte_pool, sizeof(TX_BYTE_POOL));