Ignore:
Timestamp:
Apr 27, 2016, 4:54:34 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
string
Children:
9ea58ca
Parents:
7ea1b3a
Message:

implemented some of code of vbytesm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/strings/src/internal/VbyteSM.c

    r7ea1b3a r8243cf9  
    11#include "VbyteSM.h"
     2#include "tools.h"
     3
     4void AddThisAfter(HandleNode_t* const this, HandleNode_t* n)
     5{
     6        this->next = n->next;
     7        this->previous = n;
     8        HandleNode_t* n_next = n->next;
     9        n_next->previous = this;
     10        n->next = this;
     11}
     12
     13void DeleteNode(HandleNode_t* const this)
     14{
     15        HandleNode_t* next = this->next;
     16        HandleNode_t* prev = this->previous;
     17
     18        next->previous = prev;
     19        prev->next = next;
     20}
     21
     22void MoveThisAfter(HandleNode_t* const this, const HandleNode_t* rhs)
     23{
     24        assertf( this->string < rhs->string,
     25        "VbyteSM: Error - Cannot move byte string starting at: %lX after byte string starting at: %lX and keep handles in ascending order",
     26        (unsigned long int)this->string,
     27        (unsigned long int)rhs->string);
     28
     29        HandleNode_t* i;
     30        for(i = rhs->next;
     31            i->string && this->string > i->string;
     32            i = i->next );
     33
     34        if( this != i->previous )
     35        {
     36                DeleteNode(this);
     37                AddThisAfter(this, i->previous);
     38        }
     39}
Note: See TracChangeset for help on using the changeset viewer.