180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTagList.h"
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTagList::~SkTagList()
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru{
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkTagList* SkTagList::Find(SkTagList* rec, U8CPU tag)
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru{
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkASSERT(tag < kSkTagListCount);
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    while (rec != NULL)
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    {
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (rec->fTag == tag)
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            break;
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        rec = rec->fNext;
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    return rec;
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkTagList::DeleteTag(SkTagList** head, U8CPU tag)
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru{
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkASSERT(tag < kSkTagListCount);
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTagList* rec = *head;
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTagList* prev = NULL;
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    while (rec != NULL)
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    {
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkTagList* next = rec->fNext;
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (rec->fTag == tag)
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            if (prev)
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                prev->fNext = next;
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            else
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                *head = next;
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            delete rec;
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            break;
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        prev = rec;
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        rec = next;
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkTagList::DeleteAll(SkTagList* rec)
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru{
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    while (rec)
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    {
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkTagList* next = rec->fNext;
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        delete rec;
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        rec = next;
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
63