@frida/http
Version:
Node.js's http module for Frida
23 lines (18 loc) • 526 B
JavaScript
// This is a free list to avoid creating so many of the same object.
export default function FreeList(name, max, constructor) {
this.name = name;
this.constructor = constructor;
this.max = max;
this.list = [];
}
FreeList.prototype.alloc = function() {
return this.list.length ? this.list.pop() :
this.constructor.apply(this, arguments);
};
FreeList.prototype.free = function(obj) {
if (this.list.length < this.max) {
this.list.push(obj);
return true;
}
return false;
};