public int alloc(int size) {
		int i, prev_i = 0;

		for (i = this.head.s_free.next; i != 0; i = this.nf[i].free.next) {
			if (this.nf[i].free.size >= size)
				break;
			prev_i = i;
		}

		// there is no free node
		if (i == 0) {
			System.err.format("alloc:NO FREE NODE\n");
			return 0;
		}
		
		if (prev_i == 0) {		// the head node
			if (size == this.nf[i].free.size) 
				this.head.s_free.next = this.nf[i].free.next;
			else {
				this.nf[i + size].free.size = this.nf[i].free.size - size;
				this.head.s_free.next = i + size;
				this.nf[i + size].free.next = this.nf[i].free.next;
			}
		}
		else {					// not the head node
			if (size == this.nf[i].free.size) 
				this.nf[prev_i].free.next = this.nf[i].free.next;
			else	{
				this.nf[i + size].free.size = this.nf[i].free.size - size;
				this.nf[prev_i].free.next = i + size;
				this.nf[i + size].free.next = this.nf[i].free.next;
			}
		}
		this.head.f_size -= size;
		return i;
	}