Changeset 8243cf9


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

implemented some of code of vbytesm

Location:
src/examples/strings
Files:
1 added
2 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}
  • src/examples/strings/src/internal/VbyteSM.h

    r7ea1b3a r8243cf9  
    11#pragma once
     2
     3#include <stdlib>
    24
    35typedef char char_t;
     
    1416        HandleNode_t* previous;
    1517};
    16 
    17 static inline void ctor(HandleNode_t* const this);
    18 static inline void ctor(HandleNode_t* const this, VbyteHeap_t* heap);
    19 static inline void dtor(HandleNode_t* const this);
    2018
    2119void DeleteNode(HandleNode_t* const this);
     
    4038        HandleNode_t Header;
    4139};
    42 
    43 static inline void ctor(VbyteHeap* const this, int size);
    44 static inline void dtor(VbyteHeap* const this);
    4540
    4641void compaction(VbyteHeap* const this);
     
    8479        this->ExtVbyte = (void*)( this->StartVbyte + this->CurrSize );
    8580
    86         ctor(&this->Header);
     81        ctor((HandleNode_t* const)&this->Header);
    8782        this->Header.next = &this->Header;
    8883        this->Header.previous = &this->Header;
Note: See TracChangeset for help on using the changeset viewer.