source: src/examples/strings/src/internal/VbyteSM.c @ 8243cf9

string
Last change on this file since 8243cf9 was 8243cf9, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

implemented some of code of vbytesm

  • Property mode set to 100644
File size: 901 bytes
RevLine 
[020a349]1#include "VbyteSM.h"
[8243cf9]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 TracBrowser for help on using the repository browser.