new_Hesoprod(ASL_pfgh *asl, ograd *L, ograd *R, real coef) #endif { Hesoprod *h, **hp, *h1, *h2; int kh; Char **mblk_free; ACQUIRE_DTOA_LOCK(HESOPROD_LOCK); if (!(h = asl->P.hop_free)) { mblk_free = asl->mblk_free; kh = asl->P.khesoprod; while(kh < 8 && !mblk_free[kh]) kh++; asl->P.khesoprod = kh; h = h1 = (Hesoprod *)new_mblk(kh); h2 = h + (sizeof(Char*) << kh)/sizeof(Hesoprod) - 1; while(h1 < h2) h1 = h1->next = h1 + 1; h1->next = 0; } asl->P.hop_free = h->next; FREE_DTOA_LOCK(HESOPROD_LOCK); h->left = L; h->right = R; h->coef = coef; hp = asl->P.otodo + R->varno; h->next = *hp; *hp = h; }
void Bfree (Bigint *v) { if (v) { if (v->k > Kmax) free((void*)v); else { ACQUIRE_DTOA_LOCK(0); v->next = freelist[v->k]; freelist[v->k] = v; FREE_DTOA_LOCK(0); } } }
static void Bfree(Bigint ** freelist, Bigint *v) { if (v) { // if (v->k > Kmax) // { // free((void*)v); // } // else { ACQUIRE_DTOA_LOCK(0); v->next = freelist[v->k]; freelist[v->k] = v; FREE_DTOA_LOCK(0); } } }
Bigint *Balloc (int k) { int x; Bigint *rv; #ifndef Omit_Private_Memory unsigned int len; #endif ACQUIRE_DTOA_LOCK(0); /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ /* but this case seems very unlikely. */ if (k <= Kmax && (rv = freelist[k]) !=0) { freelist[k] = rv->next; } else { x = 1 << k; #ifdef Omit_Private_Memory rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); if (rv == NULL) return NULL; #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) /sizeof(double); if (k <= Kmax && (size_t) (pmem_next - private_mem + len) <= PRIVATE_mem) { rv = (Bigint*)pmem_next; pmem_next += len; } else { rv = (Bigint*)MALLOC(len*sizeof(double)); if (rv == NULL) return NULL; } #endif rv->k = k; rv->maxwds = x; } FREE_DTOA_LOCK(0); rv->sign = rv->wds = 0; return rv; }
static Bigint * Balloc(AllocatedBlock ** aBlocks, Bigint ** freelist, int k) { int x; Bigint *rv; ACQUIRE_DTOA_LOCK(0); if ((rv = freelist[k])) { freelist[k] = rv->next; } else { x = 1 << k; rv = (Bigint *)safe_malloc(aBlocks, sizeof(Bigint) + (x-1)*sizeof(UINT_32)); rv->k = k; rv->maxwds = x; } FREE_DTOA_LOCK(0); rv->sign = rv->wds = 0; return rv; }
mem_ASL(ASL *asl, unsigned int len) #endif { fint k; char *memNext; if (len >= 256) return M1alloc(len); #ifdef Double_Align len = (len + (sizeof(real)-1)) & ~(sizeof(real)-1); #else len = (len + (sizeof(int)-1)) & ~(sizeof(int)-1); #endif ACQUIRE_DTOA_LOCK(MEM_LOCK); memNext = asl->i.memNext; if (memNext + len >= asl->i.memLast) { memNext = (char *)M1alloc(k = Egulp*Sizeof(expr) + len); asl->i.memLast = memNext + k; } asl->i.memNext = memNext + len; FREE_DTOA_LOCK(MEM_LOCK); return memNext; }