Project

General

Profile

Feature #12754

Want to use prepared buffer with `Array#pack`

Added by usa (Usaku NAKAMURA) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-dev:49798]

Description

Array#pack always returns new allocated String, but sometimes users want to use prepared buffer, especially the packed size is too large.
I often uses Fiddle to call OS APIs, and encounter this problem as every time.
I recommend to add keyword arguments for the purpose.

buf = '\0'*(32 * 1024 * 1024)
# ...
ary.pack(LONG_FORMAT, buffer: buf, offset: 4 * 1024) # returns `buf`

Associated revisions

Revision 0dd9c302
Added by usa (Usaku NAKAMURA) about 2 years ago

Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56957
Added by usa (Usaku NAKAMURA) about 2 years ago

Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

Revision 56957
Added by usa (Usaku NAKAMURA) about 2 years ago

Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

Revision 56957
Added by usa (Usaku NAKAMURA) about 2 years ago

Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

Revision 56957
Added by usa (Usaku NAKAMURA) about 2 years ago

Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

History

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

Array#pack provides @ for offset.

#2

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Tracker changed from Bug to Feature
#4

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Status changed from Open to Closed

Applied in changeset r56957.


Supports buffer and offset in Array#pack

  • pack.c (pack_pack): Supports buffer and offset in Array#pack. [Feature #12754] [ruby-dev:49798]

Also available in: Atom PDF