public void Free() { if (_onAuto != null) { Globals.delete(_onAuto); } if (_onCleared != null) { Globals.delete(_onCleared); } if (_onShunt != null) { Globals.delete(_onShunt); } if (_onClick != null) { Globals.delete(_onClick); } if (_onCross != null) { Globals.delete(_onCross); } if (_onInit != null) { Globals.delete(_onInit); } if (_onUpdate != null) { Globals.delete(_onUpdate); } }
// Allocate enough entries to store 'maxInstances' items. // This is useful when a Array must be copied into another // Array, to avoid unnecessary realloc() calls. public void Reserve(int maxInstances) { if (_maxInstances >= maxInstances) { return; } if (_instances == null || _instances.Length == 0) { _instances = new T[maxInstances]; //(T *)malloc(maxInstances * sizeof(T)); } else { T[] insts = new T[maxInstances]; for (int xx = 0; xx < _nInstances; ++xx) { insts[xx] = _instances[xx]; } Globals.delete(_instances); _instances = insts; // _instances = (T *)realloc(_instances, maxInstances * sizeof(T)); } if (_instances == null || _instances.Length == 0) { Globals.Panic("out of memory"); } _maxInstances = maxInstances; }
// Add an item to the set public void Add(T item) { if (_nInstances >= _maxInstances) { _maxInstances += Array_INCREMENT; if (_instances == null || _instances.Length == 0) { _instances = new T[_maxInstances]; } else { T[] insts = new T[_maxInstances]; for (int xx = 0; xx < _nInstances; ++xx) { insts[xx] = _instances[xx]; } Globals.delete(_instances); _instances = insts; } if (_instances == null || _instances.Length == 0) { Globals.Panic("out of memory"); } // Erik: Disabled following line // memset(_instances + _maxInstances - Array_INCREMENT, // 0, Array_INCREMENT * sizeof(T)); } _instances[_nInstances++] = item; }
public void Clear() { while (_firstItem != null) { _lastItem = _firstItem._next; Globals.delete(_firstItem); _firstItem = _lastItem; } }
public void Release() { if (_instances != null && _instances.Length > 0) { Globals.delete(_instances); } _nInstances = 0; _maxInstances = 0; _instances = null; }
// Delete all objects contained in the Array, // effectively releasing all memory used by the Array. // This can only be called when the Array "owns" // the objects stored in it. public void DeleteAll() { int i; for (i = _nInstances - 1; i >= 0; --i) { Globals.delete(_instances[i]); } Release(); }
public void Clear() { while (_firstItem != null) { T obj = _firstItem; _firstItem = obj._next; Globals.delete(obj); } _firstItem = _lastItem = null; _nItems = 0; }
public void DeleteAt(int pos) { if (pos >= base.Length()) { return; } T item = base.At(pos); base.RemoveAt(pos); Globals.delete(item); }
static CSVFile exists(string rootDir, string fileName) { string path; CSVFile csv; path = String.Format(wxPorting.T("%s/%s.txt"), rootDir, fileName); csv = new CSVFile(path); if (csv.Load()) { return(csv); } Globals.delete(csv); return(null); }