1 /* ========================================================================== */ 2 /* === UMF_mem_init_memoryspace ============================================= */ 3 /* ========================================================================== */ 4 5 /* -------------------------------------------------------------------------- */ 6 /* Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com. */ 7 /* All Rights Reserved. See ../Doc/License.txt for License. */ 8 /* -------------------------------------------------------------------------- */ 9 10 /* The UMF_mem_* routines manage the Numeric->Memory memory space. */ 11 12 #include "umf_internal.h" 13 #include "umf_mem_init_memoryspace.h" 14 15 /* initialize the LU and element workspace (Numeric->Memory) */ 16 UMF_mem_init_memoryspace(NumericType * Numeric)17GLOBAL void UMF_mem_init_memoryspace 18 ( 19 NumericType *Numeric 20 ) 21 { 22 Unit *p ; 23 24 ASSERT (Numeric != (NumericType *) NULL) ; 25 ASSERT (Numeric->Memory != (Unit *) NULL) ; 26 ASSERT (Numeric->size >= 3) ; 27 DEBUG0 (("Init memory space, size "ID"\n", Numeric->size)) ; 28 29 Numeric->ngarbage = 0 ; 30 Numeric->nrealloc = 0 ; 31 Numeric->ncostly = 0 ; 32 Numeric->ibig = EMPTY ; 33 Numeric->ihead = 0 ; 34 Numeric->itail = Numeric->size ; 35 36 #ifndef NDEBUG 37 UMF_allocfail = FALSE ; 38 #endif 39 40 /* allocate the 2-unit tail marker block and initialize it */ 41 Numeric->itail -= 2 ; 42 p = Numeric->Memory + Numeric->itail ; 43 DEBUG2 (("p "ID" tail "ID"\n", (Int) (p-Numeric->Memory), Numeric->itail)) ; 44 Numeric->tail_usage = 2 ; 45 p->header.prevsize = 0 ; 46 p->header.size = 1 ; 47 48 /* allocate a 1-unit head marker block at the head of memory */ 49 /* this is done so that an offset of zero is treated as a NULL pointer */ 50 Numeric->ihead++ ; 51 52 /* initial usage in Numeric->Memory */ 53 Numeric->max_usage = 3 ; 54 Numeric->init_usage = Numeric->max_usage ; 55 56 /* Note that UMFPACK_*symbolic ensures that Numeric->Memory is of size */ 57 /* at least 3, so this initialization will always succeed. */ 58 59 #ifndef NDEBUG 60 DEBUG2 (("init_memoryspace, all free (except one unit at head\n")) ; 61 UMF_dump_memory (Numeric) ; 62 #endif 63 64 } 65