mclVector* mclvInstantiate ( mclVector* dst_vec , dim new_n_ivps , const mclIvp* src_ivps ) { mclIvp* new_ivps ; dim old_n_ivps ; if (!dst_vec && !(dst_vec = mclvInit(NULL))) /* create */ return NULL ; old_n_ivps = dst_vec->n_ivps /* I've had a suspicion that some reallocs might be too lazy * to reuse shrunk array space. */ ; if (old_n_ivps / 2 > new_n_ivps) { new_ivps = mcxAlloc(new_n_ivps * sizeof new_ivps[0], ENQUIRE_ON_FAIL) ; if (new_ivps && !src_ivps) memcpy(new_ivps, dst_vec->ivps, new_n_ivps * sizeof new_ivps[0]) ; mcxFree(dst_vec->ivps) ; dst_vec->ivps = new_ivps ; } else dst_vec->ivps = mcxRealloc(dst_vec->ivps, new_n_ivps * sizeof new_ivps[0], ENQUIRE_ON_FAIL) ; if ( !dst_vec->ivps && new_n_ivps ) { mcxMemDenied(stderr, "mclvInstantiate", "mclIvp", new_n_ivps) ; return NULL ; } /* ^ do not free; *dst_vec could be array element */ new_ivps = dst_vec->ivps ; if (!src_ivps) /* resize */ { dim k = old_n_ivps ; while (k < new_n_ivps) { mclpInit(new_ivps + k) ; k++ ; } } else if (src_ivps && new_n_ivps) /* copy */ memcpy(new_ivps, src_ivps, new_n_ivps * sizeof(mclIvp)) ; dst_vec->n_ivps = new_n_ivps ; return dst_vec ; }
; if (n > MCLX_COMPOSE_NTHREAD_MAX_SUGGESTED) n = MCLX_COMPOSE_NTHREAD_MAX_SUGGESTED ; return n ; } /* fixme: callers of mclxcomposeprepare need to use n_jobs */ mclxComposeHelper* mclxComposePrepare ( const mclMatrix* mx1 , const mclMatrix* mx2_unused cpl__unused , int n_threads ) { int i ; mclxComposeHelper* ch = mcxRealloc ( NULL, sizeof(mclxComposeHelper), EXIT_ON_FAIL) ; if (n_threads <= 0) n_threads = 1 ; ch->n_jobs = n_threads ; ch->iovs = mcxAlloc(ch->n_jobs * sizeof ch->iovs[0], EXIT_ON_FAIL) ; for (i=0; i<ch->n_jobs; i++) ch->iovs[i] = mcxNAlloc ( N_ROWS(mx1) + 1 , sizeof(mclIOV) , mclIOVinit_v , EXIT_ON_FAIL ) ; return ch