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

Tehreer / SheenBidi / 20111016346

10 Dec 2025 07:36PM UTC coverage: 95.58% (-0.2%) from 95.796%
20111016346

push

github

mta452
[lib] Minor improvements

65 of 72 new or added lines in 3 files covered. (90.28%)

8 existing lines in 1 file now uncovered.

3936 of 4118 relevant lines covered (95.58%)

452189.36 hits per line

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

74.19
/Source/Object.c
1
/*
2
 * Copyright (C) 2025 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 <SheenBidi/SBBase.h>
20
#include <SheenBidi/SBConfig.h>
21

22
#include "AtomicUInt.h"
23
#include "Memory.h"
24
#include "SBAssert.h"
25
#include "Object.h"
26

UNCOV
27
SB_INTERNAL void ObjectBaseInitialize(ObjectBaseRef objectBase)
×
28
{
UNCOV
29
    MemoryInitialize(&objectBase->memory);
×
UNCOV
30
    objectBase->finalize = NULL;
×
UNCOV
31
    objectBase->retainCount = 0;
×
UNCOV
32
}
×
33

34
SB_INTERNAL ObjectRef ObjectCreate(const SBUInteger *chunkSizes, SBUInteger chunkCount,
2,586,803✔
35
    void **outPointers, FinalizeFunc finalizer)
36
{
37
    ObjectBaseRef base = NULL;
2,586,803✔
38
    Memory memory;
2,586,803✔
39

40
    /* Number of chunks MUST be greater than or equal to one. */
41
    SBAssert(chunkCount >= 1);
2,586,803✔
42
    /* Size of first chunk MUST be greater than the size of ObjectBase structure. */
43
    SBAssert(chunkSizes[0] > sizeof(ObjectBase));
2,586,803✔
44

45
    MemoryInitialize(&memory);
2,586,803✔
46

47
    if (MemoryAllocateChunks(&memory, MemoryTypePermanent, chunkSizes, chunkCount, outPointers)) {
2,586,803✔
48
        base = outPointers[0];
2,586,803✔
49
        base->memory = memory;
2,586,803✔
50
        base->finalize = finalizer;
2,586,803✔
51

52
        AtomicUIntInitialize(&base->retainCount, 1);
2,586,803✔
53
    }
54

55
    return base;
2,586,803✔
56
}
57

UNCOV
58
SB_INTERNAL SBUInteger ObjectGetRetainCount(ObjectRef object)
×
59
{
UNCOV
60
    ObjectBaseRef base = (ObjectBaseRef)object;
×
61

UNCOV
62
    return AtomicUIntLoad(&base->retainCount);
×
63
}
64

65
SB_INTERNAL ObjectRef ObjectRetain(ObjectRef object)
1,724,173✔
66
{
67
    ObjectBaseRef base = (ObjectBaseRef)object;
1,724,173✔
68

69
    AtomicUIntIncrement(&base->retainCount);
1,724,173✔
70

71
    return object;
1,724,173✔
72
}
73

74
SB_INTERNAL void ObjectRelease(ObjectRef object)
4,310,976✔
75
{
76
    ObjectBaseRef base = (ObjectBaseRef)object;
4,310,976✔
77

78
    if (AtomicUIntDecrement(&base->retainCount) == 0) {
4,310,976✔
79
        if (base->finalize) {
2,586,803✔
80
            base->finalize(object);
862,664✔
81
        }
82

83
        MemoryFinalize(&base->memory);
2,586,803✔
84
    }
85
}
4,310,976✔
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