/// <summary> /// Expand F-block if required /// </summary> internal void CheckFreeQueueSize() { if (!fbqe_is_expanding) { if (this.FREE < DEFS.FBQE_MIN_FREE_NUMBER) { fbqe_is_expanding = true; Space.ExtendSpace(F_Object, DEFS.FBQE_ALLOCATION_LENGTH); // Extend buffer byte[] old_buffer = buffer; // F-block buffer buffer = new byte[F_Object.Size]; for (int i = 0; i < old_buffer.Length; i++) { buffer[i] = old_buffer[i]; } old_buffer = null; // Update current LAST_Q FBQE FBQE fp = this.GetFBQE(this.LAST_Q); fp.NEXT = this.MAX; // 1st FBQE in the last block SerializeFBQE(fp); int old_maxn = this.MAX; // Max (before) this.MAX += DEFS.FBQE_ALLOCATION_NUMBER; // Max(after) this.FREE += DEFS.FBQE_ALLOCATION_NUMBER; // Free(after) this.LAST_Q = this.MAX - 1; // Last in free queue (after) for (int i = 0; i < DEFS.FBQE_ALLOCATION_NUMBER; i++) { this.CreateFBQE(old_maxn + i); } // Update current PREV ref in the 1st new FBQE FBQE fn = this.GetFBQE(old_maxn); fn.PREV = fp.index; SerializeFBQE(fn); fbqe_is_expanding = false; } } }
/// <summary> /// Add reference /// </summary> /// <param name="rf"></param> /// <returns></returns> internal bool add_ref(long rf) { long[] refs = REFS; for (int i = 0; i < refs.Length; i++) { if (refs[i] == rf) { return(true); } } if ((ALLOCATION.Size - AVLNODE_SIZE) < 8) { long ext_size = this.UNIQUE ? DEFS.MIN_SPACE_ALLOCATION_CHUNK : (DEFS.MIN_SPACE_ALLOCATION_CHUNK * 3); sp.ExtendSpace(ALLOCATION, ext_size); } ALLOCATION.Write(REF_POS + (REF_COUNT * 8), rf); REF_COUNT++; return(true); }