* lu_realloc_obj() * * reallocate Li,Lx and/or Ui,Ux and/or Wi,Wx as requested in xstore * * Return: BASICLU_OK or BASICLU_ERROR_out_of_memory */
| 52 | * Return: BASICLU_OK or BASICLU_ERROR_out_of_memory |
| 53 | */ |
| 54 | static lu_int lu_realloc_obj(struct basiclu_object *obj) |
| 55 | { |
| 56 | double *xstore = obj->xstore; |
| 57 | lu_int addmemL = xstore[BASICLU_ADD_MEMORYL]; |
| 58 | lu_int addmemU = xstore[BASICLU_ADD_MEMORYU]; |
| 59 | lu_int addmemW = xstore[BASICLU_ADD_MEMORYW]; |
| 60 | double realloc_factor = fmax(1.0, obj->realloc_factor); |
| 61 | lu_int nelem; |
| 62 | lu_int status = BASICLU_OK; |
| 63 | |
| 64 | if (status == BASICLU_OK && addmemL > 0) |
| 65 | { |
| 66 | nelem = xstore[BASICLU_MEMORYL] + addmemL; |
| 67 | nelem *= realloc_factor; |
| 68 | status = lu_reallocix(nelem, &obj->Li, &obj->Lx); |
| 69 | if (status == BASICLU_OK) |
| 70 | xstore[BASICLU_MEMORYL] = nelem; |
| 71 | } |
| 72 | if (status == BASICLU_OK && addmemU > 0) |
| 73 | { |
| 74 | nelem = xstore[BASICLU_MEMORYU] + addmemU; |
| 75 | nelem *= realloc_factor; |
| 76 | status = lu_reallocix(nelem, &obj->Ui, &obj->Ux); |
| 77 | if (status == BASICLU_OK) |
| 78 | xstore[BASICLU_MEMORYU] = nelem; |
| 79 | } |
| 80 | if (status == BASICLU_OK && addmemW > 0) |
| 81 | { |
| 82 | nelem = xstore[BASICLU_MEMORYW] + addmemW; |
| 83 | nelem *= realloc_factor; |
| 84 | status = lu_reallocix(nelem, &obj->Wi, &obj->Wx); |
| 85 | if (status == BASICLU_OK) |
| 86 | xstore[BASICLU_MEMORYW] = nelem; |
| 87 | } |
| 88 | return status; |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * isvalid() - test if @obj is an allocated BASICLU object |
no test coverage detected