Wombat Queue Destroy


Sam Wilson <Sam.Wilson@...>
 

Hello!

I'm trying to use Wombat Queue, but I can't figure out how to safely
free a queue when the creation fails. Here's my example:

wombatQueue queue;
wombatQueueStatus status = wombatQueue_allocate(&queue);
if (WOMBAT_QUEUE_OK != status) {
return; // log the error state or what have you
}

status = wombatQueue_create(queue, MAX_SIZE, INITIAL_SIZE,
CHUNK_SIZE);
if (WOMBAT_QUEUE_OK != status) {
wombatQueue_destroy(queue); // Doesn't work because the
// queue hasn't been created.

// So how do I free the memory allocated by
// wombatQueue_allocate?
}

Thanks for your help,
Sam


Damian Maguire
 

Hey Sam,

Unfortunately this is a weakness in the API for the Wombat Queue implementation - it really should have a wombatQueue_deallocate, but it isn't presently available. If you'd like to raise an issue in bugzilla (bugs.openmama.org) we can look at getting it added. Better yet, we'd be happy to accept a patch which addresses the issue in the queue.

Thanks, 

Damian


On Tue, Sep 2, 2014 at 7:20 PM, Sam Wilson <Sam.Wilson@...> wrote:
Hello!

I'm trying to use Wombat Queue, but I can't figure out how to safely
free a queue when the creation fails. Here's my example:

     wombatQueue queue;
     wombatQueueStatus status = wombatQueue_allocate(&queue);
     if (WOMBAT_QUEUE_OK != status) {
         return; // log the error state or what have you
     }

     status = wombatQueue_create(queue, MAX_SIZE, INITIAL_SIZE,
                                 CHUNK_SIZE);
     if (WOMBAT_QUEUE_OK != status) {
         wombatQueue_destroy(queue); // Doesn't work because the
                                     // queue hasn't been created.

         // So how do I free the memory allocated by
         // wombatQueue_allocate?
     }

Thanks for your help,
Sam
_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
https://lists.openmama.org/mailman/listinfo/openmama-dev


Sam Wilson <Sam.Wilson@...>
 

Hey Damian,

I'm just getting around to looking at this now. Would you prefer a patch that adds wombatQueue_deallocate, or one that merges both wombatQueue_allocate and wombatQueue_create into wombatQueue_allocate and makes wombatQueue_create a dummy function?

The advantage of the first option is that the API works more like it was intended, but it will break any current users of wombat queues.

The second option retains backward compatibility, but you end up losing the benefits of having separate allocate/create functions.

Thanks,
Sam

On 14-09-03 05:34 AM, Damian Maguire wrote:
Hey Sam,

Unfortunately this is a weakness in the API for the Wombat Queue implementation - it really should have a wombatQueue_deallocate, but it isn't presently available. If you'd like to raise an issue in bugzilla (bugs.openmama.org) we can look at getting it added. Better yet, we'd be happy to accept a patch which addresses the issue in the queue.

Thanks, 

Damian


On Tue, Sep 2, 2014 at 7:20 PM, Sam Wilson <Sam.Wilson@...> wrote:
Hello!

I'm trying to use Wombat Queue, but I can't figure out how to safely
free a queue when the creation fails. Here's my example:

     wombatQueue queue;
     wombatQueueStatus status = wombatQueue_allocate(&queue);
     if (WOMBAT_QUEUE_OK != status) {
         return; // log the error state or what have you
     }

     status = wombatQueue_create(queue, MAX_SIZE, INITIAL_SIZE,
                                 CHUNK_SIZE);
     if (WOMBAT_QUEUE_OK != status) {
         wombatQueue_destroy(queue); // Doesn't work because the
                                     // queue hasn't been created.

         // So how do I free the memory allocated by
         // wombatQueue_allocate?
     }

Thanks for your help,
Sam
_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
https://lists.openmama.org/mailman/listinfo/openmama-dev



Damian Maguire
 

Hey Sam,

Personally I would be inclined towards the addition of wombatQueue_deallocate, and then having this called within the context of the existing wombatQueue_destroy. This would result in no change to behaviour for current client applications (destroy would free the memory as it currently does, so a separate call to deallocate would not be needed), but would allow applications to clean up memory where the allocate has succeeded but create has failed (as in your example).

Thanks, 

Damian  



On Tue, Oct 28, 2014 at 2:36 PM, Sam Wilson <Sam.Wilson@...> wrote:
Hey Damian,

I'm just getting around to looking at this now. Would you prefer a patch that adds wombatQueue_deallocate, or one that merges both wombatQueue_allocate and wombatQueue_create into wombatQueue_allocate and makes wombatQueue_create a dummy function?

The advantage of the first option is that the API works more like it was intended, but it will break any current users of wombat queues.

The second option retains backward compatibility, but you end up losing the benefits of having separate allocate/create functions.

Thanks,
Sam


On 14-09-03 05:34 AM, Damian Maguire wrote:
Hey Sam,

Unfortunately this is a weakness in the API for the Wombat Queue implementation - it really should have a wombatQueue_deallocate, but it isn't presently available. If you'd like to raise an issue in bugzilla (bugs.openmama.org) we can look at getting it added. Better yet, we'd be happy to accept a patch which addresses the issue in the queue.

Thanks, 

Damian


On Tue, Sep 2, 2014 at 7:20 PM, Sam Wilson <Sam.Wilson@...> wrote:
Hello!

I'm trying to use Wombat Queue, but I can't figure out how to safely
free a queue when the creation fails. Here's my example:

     wombatQueue queue;
     wombatQueueStatus status = wombatQueue_allocate(&queue);
     if (WOMBAT_QUEUE_OK != status) {
         return; // log the error state or what have you
     }

     status = wombatQueue_create(queue, MAX_SIZE, INITIAL_SIZE,
                                 CHUNK_SIZE);
     if (WOMBAT_QUEUE_OK != status) {
         wombatQueue_destroy(queue); // Doesn't work because the
                                     // queue hasn't been created.

         // So how do I free the memory allocated by
         // wombatQueue_allocate?
     }

Thanks for your help,
Sam
_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
https://lists.openmama.org/mailman/listinfo/openmama-dev