Skip to content

Commit

Permalink
fix: use deinitialize of UnsafeMutablePointer
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOF committed Apr 2, 2024
1 parent c324063 commit ab2783d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private final class ClassAAAttribution {

func attributionToken() throws -> String {
let error = UnsafeMutablePointer<NSError?>.allocate(capacity: 1)
defer { error.deallocate() }
error.initialize(to: nil)

let result = {
let function = unsafeBitCast(
Expand All @@ -72,6 +72,9 @@ private final class ClassAAAttribution {
throw error
}

error.deinitialize(count: 1)
error.deallocate()

return result
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/Concurrency/Atomic/Atomic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public final class Atomic<Value> {
deinit {
pthread_mutex_destroy(lock)

lock.deinitialize(count: 1)
lock.deallocate()
}

Expand Down
1 change: 1 addition & 0 deletions Source/Concurrency/Lock/Lock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public final class Lock {
deinit {
pthread_mutex_destroy(token)

token.deinitialize(count: 1)
token.deallocate()
}

Expand Down
1 change: 1 addition & 0 deletions Source/Concurrency/Mutex/Mutex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public final class Mutex {
deinit {
pthread_mutex_destroy(lock)

lock.deinitialize(count: 1)
lock.deallocate()
}

Expand Down

0 comments on commit ab2783d

Please sign in to comment.