]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Updated error checking of forb_sequence_alloc_buf()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 21 May 2009 11:08:05 +0000 (13:08 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 21 May 2009 11:08:05 +0000 (13:08 +0200)
fres/cbroker/fcb.c
frsh_api/frsh_spare_capacity.c

index 4c8efcdcd62ec2fcf9620a963e9a9cfab5e9e37e..116789332bf555a41bd083250c1ce9656f234ea0 100644 (file)
@@ -416,7 +416,9 @@ rebalance_spare_capacity_and_reserve(struct resource *resource,
        fres_block_spare_capacity *s;
 
        fres_contract_ptr_seq contracts;
-       forb_sequence_alloc_buf(contracts, rl->length);
+       if (!forb_sequence_alloc_buf(contracts, rl->length)) {
+               return errno;
+       }
        contracts._length = rl->length;
        i=0;
        /* Initialize optimization */
@@ -531,7 +533,9 @@ change_vreses(struct fcb *fcb, fres_contract_ptr_seq *schedulable_contracts)
        int i, ret;
        CORBA_Environment ev;
        
-       forb_sequence_alloc_buf(vreses, schedulable_contracts->_length);
+       if (!forb_sequence_alloc_buf(vreses, schedulable_contracts->_length)) {
+               return errno;
+       }
        vreses._length = 0;
        
        for (i=0; i<schedulable_contracts->_length; i++) {
@@ -617,8 +621,7 @@ negotiate_contracts(fres_contract_broker obj,
        /* Allocate all the needed memory before doing reservation. If
         * there is no enough memory, it has no sense to call resource
         * manager. */
-       forb_sequence_alloc_buf(commit_ids, rl.length);
-       if (!commit_ids._buffer) {
+       if (!forb_sequence_alloc_buf(commit_ids, rl.length)) {
                ret = errno;
                goto err_free_fcb_contracts;
        }
@@ -687,8 +690,7 @@ negotiate_contracts(fres_contract_broker obj,
 
 
        /* Return IDs and delete canceled contracts from out database */
-       forb_sequence_alloc_buf(**ids_out, contracts->_length);
-       if (!(*ids_out)->_buffer) {
+       if (!forb_sequence_alloc_buf(**ids_out, contracts->_length)) {
                ev->major = FORB_EX_NO_MEMORY;
                goto err_cancel_contracts;
        }
index 5806c7c3b0bf018d70395eda5e29ee6b40b42ddd..77b5bb113fd31cdcb22e16e0d76d89d0e0e657e1 100644 (file)
@@ -103,7 +103,9 @@ int frsh_contract_set_reclamation_params
 
        if (utilization_set) {
                int i;
-               forb_sequence_alloc_buf(s->variants, utilization_set->size);
+               if (!forb_sequence_alloc_buf(s->variants, utilization_set->size)) {
+                       goto err;
+               }
                for (i=0; i<utilization_set->size; i++) {
                        struct fres_container *c = NULL;
                        fres_block_basic *b = NULL;