Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buddy-tree

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buddy-tree

Immutable buddy memory allocation

  • 2.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

buddy-tree

Immutable buddy memory allocation

Installation

npm install --save buddy-tree

Usage

import * as buddyTree from 'buddy-tree'

let tree = buddyTree.createTree(16);
[tree, address1] = buddyTree.allocate(tree, 1);
[tree, address2] = buddyTree.allocate(tree, 1);
[tree, address3] = buddyTree.allocate(tree, 4);
tree = buddyTree.deallocate(tree, address2);

Methods

buddyTree.allocate(tree, size=1)

Find a contiguous free span of memory of size and consumes it. Returns the modified tree and the address of the memory.

Consumes 2ⁿ >= size of the memory. This means in the worst case half the memory is wasted.

const tree = buddyTree.createTree(16);
const [result, address] = buddyTree.allocate(tree, 7);

buddyTree.deallocate(tree, address)

Frees all the memory consumed at the address. Returns the modified tree.

Keywords

FAQs

Package last updated on 03 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc