Project

General

Profile

Actions

Feature #12754

closed

Want to use prepared buffer with `Array#pack`

Feature #12754: Want to use prepared buffer with `Array#pack`

Added by usa (Usaku NAKAMURA) about 9 years ago. Updated almost 9 years ago.

Status:
Closed
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`

Updated by nobu (Nobuyoshi Nakada) about 9 years ago Actions #1 [ruby-dev:49799]

Array#pack provides @ for offset.

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago Actions #2

  • Tracker changed from Bug to Feature

Updated by matz (Yukihiro Matsumoto) almost 9 years ago Actions #3 [ruby-dev:49887]

Accepted.

Matz.

Updated by usa (Usaku NAKAMURA) almost 9 years ago Actions #4

  • Status changed from Open to Closed

Applied in changeset r56957.


Supports buffer and offset in Array#pack

Actions

Also available in: PDF Atom