allocateSpace().
189
private void freeAllocatedSpace(java.util.Collection sortedFreeSpaceList)
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "freeAllocatedSpace",
                        new Object[] { new Integer(sortedFreeSpaceList.size()), new Long(freeSpaceByLength.size()) });

        // Remove from the head of the sorted set until we find the first non-negative
        // address - indicating that the storage was allocated
        java.util.Iterator listIterator = sortedFreeSpaceList.iterator();
        Directory.StoreArea currentArea = null;
        while (listIterator.hasNext()) {
            currentArea = (Directory.StoreArea) listIterator.next();
            if (currentArea.byteAddress > 0)
                break;
        }

        // Did we find at least one to merge?
        if (currentArea != null) {

            // We now have a pointer to the first store area in the sorted list
            // that needs to be merged into the free space map.
            // We iterate through the free space map (which is also in order)
            // merging the entries in, and moving our pointer forwards.
            FreeSpace spaceEntry = freeSpaceByAddressHead;
            FreeSpace previousEntry = null;
            do {
                // If spaceEntry is null then we have reached the end of the list.
                // We handle this case first, because we can avoid null-checks in
                // other branches.
                // The same logic is used to handle the case where we have moved
                // past the point in the address-sorted free space list where this
                // entry would be merged, and did not find any existing entries
                // to merge it with. Merging would have been performed in branches
                // below on an earlier pass round the loop if it was possible (as
                // we would have looked at the entry that is now spaceEntry as        
                // spaceEntry.next in the below branches).
                if (spaceEntry == null || // Tail of list reached
                    spaceEntry.address > currentArea.byteAddress // Moved past insertion point without merge
                ) {
                    // Create a new entry, unless this is a zero-sized entry
                    if (currentArea.length > 0) {
                        FreeSpace newSpaceEntry =
                                        new FreeSpace(currentArea.byteAddress, currentArea.length);

                        // Link it in behind the current entry
                        newSpaceEntry.next = spaceEntry;
                        if (previousEntry != null) {
                            previousEntry.next = newSpaceEntry;
                        }
                        else {
                            // We are the new head
                            freeSpaceByAddressHead = newSpaceEntry;
                        }
                        newSpaceEntry.prev = previousEntry;
                        if (spaceEntry != null) {
                            spaceEntry.prev = newSpaceEntry;
                        }

                        // Add our extended entry into the length-sorted list
                        freeSpaceByLength.add(newSpaceEntry);

                        // Debug freespace list
                        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "ADD to freespace list");

                        // Keep track of the maximum free space count as a statistic
                        if (gatherStatistics && freeSpaceByLength.size() > maxFreeSpaceCount)
                            maxFreeSpaceCount = freeSpaceByLength.size();

                        // As we've added a new entry before the current on, we should use it next time round
                        spaceEntry = newSpaceEntry;
                        // Previous entry stayed the same - as we've inserted without moving forwards
                    }
                    // Regardless of whether we added an entry, move onto the next store area and
                    // go back round the loop.
                    if (listIterator.hasNext()) {
                        currentArea = (Directory.StoreArea) listIterator.next();
                    }
                    else
                        currentArea = null; // We've run out of entries to merge
                }
                // Can our current store entry be merged with the current free space entry.
                else if (spaceEntry.address + spaceEntry.length == currentArea.byteAddress) {
                    // We can merge this entry with the one before it.
                    // Remove from the length-sorted list and change the size
                    freeSpaceByLength.remove(spaceEntry);
                    spaceEntry.length += currentArea.length;

                    // Can we also merge it with the one after it?
                    FreeSpace nextSpaceEntry = spaceEntry.next;
                    if (nextSpaceEntry != null &&
                        currentArea.byteAddress + currentArea.length == nextSpaceEntry.address) {
                        // Remove the eliminated space entry from the length-sorted list
                        freeSpaceByLength.remove(nextSpaceEntry);

                        // Debug freespace list
                        // if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled()) trace.debug(this, cclass, methodName, "REMOVE from freespace list");

                        // Make the previous one larger
                        spaceEntry.length += nextSpaceEntry.length;
                        // Remove the next one
                        spaceEntry.next = nextSpaceEntry.next;
                        if (nextSpaceEntry.next != null) {
                            nextSpaceEntry.next.prev = spaceEntry;
                        }
                    }

                    // Add our extended entry into the length-sorted list
                    freeSpaceByLength.add(spaceEntry);

                    // We've merged this store entry now, so move onto the next one
                    // in the sorted list.
                    if (listIterator.hasNext()) {
                        currentArea = (Directory.StoreArea) listIterator.next();
                    }
                    else
                        currentArea = null; // We've run out of entries to merge
                    // Note we do not advance our position in the free space, as the
                    // current entry could also be of interest to the next store item.
                }
                // Can our current store entry be merged with the next free space entry
                // (note that the case where it merges with both is already handled).
                else if (spaceEntry.next != null &&
                         currentArea.byteAddress + currentArea.length == spaceEntry.next.address) {
                    // Remove from the length-sorted list and change the size
                    FreeSpace nextSpaceEntry = spaceEntry.next;
                    freeSpaceByLength.remove(nextSpaceEntry);
                    nextSpaceEntry.address = currentArea.byteAddress;
                    nextSpaceEntry.length += currentArea.length;

                    // Add back into the length-sorted list
                    freeSpaceByLength.add(nextSpaceEntry);

                    // We've merged this store entry now, so move onto the next one
                    // in the sorted list.
                    if (listIterator.hasNext()) {
                        currentArea = (Directory.StoreArea) listIterator.next();
                    }
                    else
                        currentArea = null; // We've run out of entries to merge
                    // Note we do not advance our position in the free space, as the
                    // current entry could also be of interest to the next store item.
                }
                // Otherwise this space entry is not interesting to us, and we
                // can simply move onto the next one.
                else {
                    previousEntry = spaceEntry;
                    spaceEntry = spaceEntry.next;
                }
                // Although looping through the free space map, our condition for
                // breaking the loop is when we've run out of entries to merge.
            } while (currentArea != null);
        }

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "freeAllocatedSpace",
                       new Object[] { new Long(freeSpaceByLength.size()) });
    }
1113322
def create_space(self):
        ''''''
        cur = self._conn.cursor()
        cur.executescript(SQL_MODEL)
        self._conn.commit()
        cur.close()
        return
1281666
def add_left_space(self, nspace=1):
        """"""
        sp = ' ' * nspace
        for item in self._rows:
            item[0] = sp + item[0]
129433
public Memory allocate(long size) {
        if(size == 0L)
            return new OffHeapMemory();

        // Allocate memory of the given size + HEADER space
        long memorySize = size + OffHeapMemory.HEADER_SIZE;
        long address = UnsafeUtil.unsafe.allocateMemory(memorySize);
        Memory m = new OffHeapMemory(address, size);
        register(m);
        return m;
    }
523196
function( w, h ){
    if( this.width !== w || this.height !== h ) {
      this.width  = w|0;
      this.height = h|0;
      this._allocate();
    }
  }
519889
def spacing(self, spacing):
        """"""
        dx, dy, dz = spacing[0], spacing[1], spacing[2]
        self.SetSpacing(dx, dy, dz)
        self.Modified()
724137
public void allocateSegments(int numberOfSegments) {
		while (getBlockCount() < numberOfSegments) {
			MemorySegment next = this.availableMemory.nextSegment();
			if (next != null) {
				this.partitionPages.add(next);
			} else {
				return;
			}
		}
	}
586552
def _expand_space(self):
        

        ## --- Expand the config space
        self._expand_config_space()

        ## --- Expand the space
        self.space_expanded = []
        for variable in self.space:
            self.space_expanded += variable.expand()
278097
protected ByteBuffer allocateBuffer() {
		if (_buffersToReuse != null && !_buffersToReuse.isEmpty()) {
			ByteBuffer bb = _buffersToReuse.poll();
			bb.rewind();
			bb.limit(bb.capacity());
			return bb;
		}
		ByteBuffer r = StaticBuffers.getInstance().byteBuffer(BUFFER_KEY, _bufferSize);
		r.limit(_bufferSize);
		return r.order(_order);
	}
220943
private long allocate_from_tail(int block_size)
    throws IOException
    {
        long block_to_alloc;

        block_to_alloc = tail_ptr;
        tail_ptr = tail_ptr + block_size;

        allocated_blocks++;
        allocated_words += block_size;

        seek_and_count(block_to_alloc);
        writeInt(- block_size);
        seek_and_count(TAIL_DPTR);
        writeLong(tail_ptr);

        return(block_to_alloc + HDR_SIZE);
    }
1368592
public static WsByteBuffer allocateByteBuffer(int size, boolean allocateDirect) {
        WsByteBuffer newBuffer = null;
        // Allocate based on the input parameter.
        if (allocateDirect) {
            newBuffer = ChannelFrameworkFactory.getBufferManager().allocateDirect(size);
        } else {
            newBuffer = ChannelFrameworkFactory.getBufferManager().allocate(size);
        }
        // Shift the limit to the capacity to maximize the space available in the buffer.
        newBuffer.limit(newBuffer.capacity());
        return newBuffer;
    }
1305786
@Override
    public Pointer allocate(long bytes, MemoryKind kind, boolean initialize) {
        Pointer ptr = NativeOpsHolder.getInstance().getDeviceNativeOps().mallocHost(bytes, 0);

        if (ptr == null || ptr.address() == 0L)
            throw new OutOfMemoryError("Failed to allocate [" + bytes + "] bytes");

        //log.info("Allocating {} bytes at MemoryManager", bytes);

        if (initialize)
            Pointer.memset(ptr, 0, bytes);

        return ptr;
    }
713954
private long[] randomSubspace(final int alldim, final int mindim, final int maxdim, final Random rand) {
    long[] dimset = BitsUtil.zero(alldim);
    // Fill with all dimensions
    int[] dims = new int[alldim];
    for(int d = 0; d < alldim; d++) {
      dims[d] = d;
    }
    // Target dimensionality:
    int subdim = mindim + rand.nextInt(maxdim - mindim);
    // Shrink the subspace to the destination size
    for(int d = 0; d < alldim - subdim; d++) {
      int s = rand.nextInt(alldim - d);
      BitsUtil.setI(dimset, dims[s]);
      dims[s] = dims[alldim - d - 1];
    }
    return dimset;
  }
1219427
@Override
    public AllocationPoint allocateMemory(DataBuffer buffer, AllocationShape requiredMemory, boolean initialize) {
        // by default we allocate on initial location
        AllocationPoint point = null;

        if (configuration.getMemoryModel() == Configuration.MemoryModel.IMMEDIATE) {
            point = allocateMemory(buffer, requiredMemory, memoryHandler.getInitialLocation(), initialize);
        } else if (configuration.getMemoryModel() == Configuration.MemoryModel.DELAYED) {
            // for DELAYED memory model we allocate only host memory, regardless of firstMemory configuration value
            point = allocateMemory(buffer, requiredMemory, AllocationStatus.HOST, initialize);
        }

        return point;
    }
889661
public synchronized void allocate(RegularFile file, int count) throws IOException {
    int newAllocatedBlockCount = allocatedBlockCount + count;
    if (newAllocatedBlockCount > maxBlockCount) {
      throw new IOException("out of disk space");
    }

    int newBlocksNeeded = Math.max(count - blockCache.blockCount(), 0);

    for (int i = 0; i < newBlocksNeeded; i++) {
      file.addBlock(new byte[blockSize]);
    }

    if (newBlocksNeeded != count) {
      blockCache.transferBlocksTo(file, count - newBlocksNeeded);
    }

    allocatedBlockCount = newAllocatedBlockCount;
  }
1104544
function _allocate(bytes) {
  var address = Module._malloc(bytes.length);
  Module.HEAPU8.set(bytes, address);

  return address;
}
364711
def allocate(n, dtype=numpy.float32):
    
    return drv.pagelocked_empty(int(n), dtype, order='C', mem_flags=drv.host_alloc_flags.PORTABLE)