/[svn]/linuxsampler/trunk/src/rtelmemorypool.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/rtelmemorypool.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by senoner, Tue Nov 11 23:30:47 2003 UTC revision 15 by schoenebeck, Sun Nov 23 21:16:49 2003 UTC
# Line 88  typedef struct _RTEListNode { Line 88  typedef struct _RTEListNode {
88                 } RTEListNode;                 } RTEListNode;
89    
90  public:  public:
91      typedef RTEListNode* NodeHandle;
92    
93    RTEList (void) {    RTEList (void) {
94      // initialize alloclist fistnode and lastnode pointers      // initialize alloclist fistnode and lastnode pointers
95      firstnode.aprev=&firstnode;      firstnode.aprev=&firstnode;
# Line 143  inline T *prev(void) { Line 145  inline T *prev(void) {
145      return(&acurrentnode->data);      return(&acurrentnode->data);
146  }  }
147    
148    /// Returns a handle for the currently selected node or NULL if the list is empty.
149    inline NodeHandle current(void) {
150        if (acurrentnode->anext == acurrentnode) return NULL;
151        return acurrentnode;
152    }
153    
154    /// Selects the node in the list respective to the node handle and returns it's data.
155    inline T* set_current(NodeHandle hNode) {
156        acurrentnode = (RTEListNode*) hNode;
157        return &acurrentnode->data;
158        //FIXME: there should be a check if the node could be selected and a return value of NULL if failed
159    }
160    
161    /// Returns true if the list is empty.
162    inline bool is_empty() {
163        return !first();
164    }
165    
166    RTEListNode firstnode;    RTEListNode firstnode;
167    RTEListNode lastnode;    RTEListNode lastnode;
168    RTEListNode *acurrentnode;    RTEListNode *acurrentnode;
# Line 384  inline  void free(T *element) { Line 404  inline  void free(T *element) {
404      RTEListNode *prevelem;      RTEListNode *prevelem;
405      RTEListNode *nextelem;      RTEListNode *nextelem;
406      RTEListNode *node;      RTEListNode *node;
407        
408      char *node_to_free=(char *)element;      char *node_to_free=(char *)element;
409      // calculate the offset of the RTEListNode (see free_offset calculation in the constructor)      // calculate the offset of the RTEListNode (see free_offset calculation in the constructor)
410      node_to_free -= free_offset;      node_to_free -= free_offset;
# Line 400  inline  void free(T *element) { Line 420  inline  void free(T *element) {
420      //printf("free returning elem=%d\n",&currentnode->data);      //printf("free returning elem=%d\n",&currentnode->data);
421    }    }
422    
423    /// Selects the current element node by providing the pointer to the sought
424    /// element's data.
425    inline void set_current(T* element) {
426        char* node    = (char*) element;
427        node         -= free_offset;  // calculate the offset of the RTEListNode (see free_offset calculation in the constructor)
428        acurrentnode  = (RTEListNode*) node;
429        //FIXME: there should be a check if the element could be selected and a respective return value
430    }
431    
432    /// Returns true if there's no allocated element.
433    inline bool is_empty() {
434        return !first();
435    }
436    
437  // empty the whole list  // empty the whole list
438  inline void empty(void) {  inline void empty(void) {
439    

Legend:
Removed from v.14  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC