• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Tehreer / SheenBidi / 28885974711

07 Jul 2026 05:31PM UTC coverage: 96.293% (-0.1%) from 96.404%
28885974711

push

github

mta452
[lib] Fix memory leaks

17 of 17 new or added lines in 4 files covered. (100.0%)

34 existing lines in 5 files now uncovered.

4000 of 4154 relevant lines covered (96.29%)

450834.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.83
/Source/API/SBMirrorLocator.c
1
/*
2
 * Copyright (C) 2014-2026 Muhammad Tayyab Akram
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
#include <stddef.h>
18

19
#include <API/SBBase.h>
20
#include <API/SBCodepoint.h>
21
#include <API/SBLine.h>
22
#include <Core/Object.h>
23
#include <Data/PairingLookup.h>
24

25
#include "SBMirrorLocator.h"
26

27
static void FinalizeMirrorLocator(ObjectRef object)
2✔
28
{
29
    SBMirrorLocatorRef locator = object;
2✔
30
    SBLineRelease(locator->_line);
2✔
31
}
2✔
32

33
SBMirrorLocatorRef SBMirrorLocatorCreate(void)
2✔
34
{
35
    const SBUInteger size = sizeof(SBMirrorLocator);
2✔
36
    void *pointer = NULL;
2✔
37
    SBMirrorLocatorRef locator;
38

39
    locator = ObjectCreate(&size, 1, &pointer, &FinalizeMirrorLocator);
2✔
40

41
    if (locator) {
2✔
42
        locator->_line = NULL;
2✔
43
        SBMirrorLocatorReset(locator);
2✔
44
    }
45

46
    return locator;
2✔
47
}
48

49
void SBMirrorLocatorLoadLine(SBMirrorLocatorRef locator, SBLineRef line, const void *stringBuffer)
861,948✔
50
{
51
    if (locator->_line) {
861,948✔
52
        SBLineRelease(locator->_line);
861,946✔
53
        locator->_line = NULL;
861,946✔
54
    }
55

56
    if (line) {
861,948✔
57
        locator->_line = SBLineRetain(line);
861,948✔
58
        locator->_stringBuffer = stringBuffer;
861,948✔
59
    }
60

61
    SBMirrorLocatorReset(locator);
861,948✔
62
}
861,948✔
63

64
const SBMirrorAgent *SBMirrorLocatorGetAgent(SBMirrorLocatorRef locator)
861,948✔
65
{
66
    return &locator->agent;
861,948✔
67
}
68

69
SBBoolean SBMirrorLocatorMoveNext(SBMirrorLocatorRef locator)
1,109,578✔
70
{
71
    SBLineRef line = locator->_line;
1,109,578✔
72

73
    if (line) {
1,109,578✔
74
        SBCodepointSequence localSequence;
1,109,578✔
75
        const SBCodepointSequence *sequence = &localSequence;
1,109,578✔
76

77
        localSequence.stringEncoding = line->stringEncoding;
1,109,578✔
78
        localSequence.stringBuffer = locator->_stringBuffer;
1,109,578✔
79
        localSequence.stringLength = line->offset + line->length;
1,109,578✔
80

81
        do {
82
            const SBRun *run = &line->fixedRuns[locator->_runIndex];
2,020,381✔
83

84
            if (run->level & 1) {
2,020,381✔
85
                SBUInteger stringIndex;
985,533✔
86
                SBUInteger stringLimit;
87

88
                stringIndex = locator->_stringIndex;
985,533✔
89
                if (stringIndex == SBInvalidIndex) {
985,533✔
90
                    stringIndex = run->offset;
737,903✔
91
                }
92
                stringLimit = run->offset + run->length;
985,533✔
93

94
                while (stringIndex < stringLimit) {
2,329,170✔
95
                    SBUInteger initialIndex = stringIndex;
1,591,267✔
96
                    SBCodepoint codepoint = SBCodepointSequenceGetCodepointAt(sequence, &stringIndex);
1,591,267✔
97
                    SBCodepoint mirror = LookupMirror(codepoint);
1,591,267✔
98

99
                    if (mirror) {
1,591,267✔
100
                        locator->_stringIndex = stringIndex;
247,630✔
101
                        locator->agent.index = initialIndex;
247,630✔
102
                        locator->agent.mirror = mirror;
247,630✔
103
                        locator->agent.codepoint = codepoint;
247,630✔
104

105
                        return SBTrue;
247,630✔
106
                    }
107
                }
108
            }
109
            
110
            locator->_stringIndex = SBInvalidIndex;
1,772,751✔
111
        } while (++locator->_runIndex < line->runCount);
1,772,751✔
112
        
113
        SBMirrorLocatorReset(locator);
861,948✔
114
    }
115
    
116
    return SBFalse;
861,948✔
117
}
118

119
void SBMirrorLocatorReset(SBMirrorLocatorRef locator)
2,585,846✔
120
{
121
    locator->_runIndex = 0;
2,585,846✔
122
    locator->_stringIndex = SBInvalidIndex;
2,585,846✔
123
    locator->agent.index = SBInvalidIndex;
2,585,846✔
124
    locator->agent.mirror = 0;
2,585,846✔
125
}
2,585,846✔
126

UNCOV
127
SBMirrorLocatorRef SBMirrorLocatorRetain(SBMirrorLocatorRef locator)
×
128
{
UNCOV
129
    return ObjectRetain((ObjectRef)locator);
×
130
}
131

132
void SBMirrorLocatorRelease(SBMirrorLocatorRef locator)
2✔
133
{
134
    ObjectRelease((ObjectRef)locator);
2✔
135
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc