# UnsafeMutableBufferPointer missing deinitialize()

**URL:** <https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030>\
**Category:** Discussion\
**Created:** [December 18, 2020, 8:19am UTC](https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030 "2020-12-18T08:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmjauer](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jmjauer/32/15911_2.png) [@jmjauer](https://forums.swift.org/u/jmjauer)\
**Post date:** [December 18, 2020, 8:19am UTC](https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030/1 "2020-12-18T08:19:24Z")

</div>

It seems that there is no deinitialize() method for UnsafeMutableBufferPointer. Is this an oversight, or is there a technical reason behind it? For example there is a dedicated deallocate() method for UnsafeMutableBufferPointer.

Greetings,  
Johannes

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [December 18, 2020, 1:00pm UTC](https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030/2 "2020-12-18T13:00:30Z")

</div>

> [@jmjauer](#):
>
> It seems that there is no deinitialize() method for UnsafeMutableBufferPointer. Is this an oversight, or is there a technical reason behind it?

Neither! It just hasn’t been designed yet. See discussion in [SE-0184](https://github.com/apple/swift-evolution/blob/master/proposals/0184-unsafe-pointers-add-missing.md).

cc @taylorswift

---

<div class="post-metadata">

**Author:** ![taylorswift](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/taylorswift/32/43413_2.png) [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Post date:** [December 18, 2020, 10:21pm UTC](https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030/3 "2020-12-18T22:21:08Z")

</div>

i think the main thing blocking `UnsafeMutableBufferPointer.deinitialize()` was that you usually don’t want to deinitialize the entire buffer at once, since if you’re using the unsafe buffer apis you’re probably doing some sort of manual memory management, which means you would be initializing and deinitializing sections of the buffer instead of the whole thing. but 3 years ago no one could agree on how these partial-initialization apis should work. so it kind of got dropped

here was the original se-0184-b thread:

> [@SE-1084 (B): buffer pointer partial initialization API](https://forums.swift.org/t/se-1084-b-buffer-pointer-partial-initialization-api/6800/11):
>
> Yes, a 0-ary operator like that would have to be hard baked into the language itself. Actually, you can just make a subscript which takes a function as an argument, and call it by passing in the ellipsis operator. Nevin Of course, the subscript notation has much more serious problems, there is 
> 
> > **···**
> >
> > On Wednesday, October 11, 2017, Kelvin Ma via swift-evolution \< swift-evolution@swift.org\> wrote: no way to allow one-sided subscripting, but disallow two-sided subscripting for the mem…

some of the email text got corrupted when it got imported into the forums (back then there were no swift forums) but the gist of it is still there

---

<div class="post-metadata">

**Author:** ![jmjauer](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jmjauer/32/15911_2.png) [@jmjauer](https://forums.swift.org/u/jmjauer)\
**Post date:** [December 19, 2020, 4:07pm UTC](https://forums.swift.org/t/unsafemutablebufferpointer-missing-deinitialize/43030/4 "2020-12-19T16:07:18Z")

</div>

thanks kelvin for the link 👍
