[ 
https://issues.apache.org/jira/browse/TS-2581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14513764#comment-14513764
 ] 

Brian Geffon edited comment on TS-2581 at 4/27/15 9:09 AM:
-----------------------------------------------------------

Guys the more i've been thinking about this I wonder if we can't just use 
exiting APIs to accomplish exactly this:

{code}
TSIOBuffer iobuf = TSIOBufferSizedCreate(indx);
TSIOBufferBlock iobuf_blk = TSIOBufferStart(iobuf);
int64_t bytes_avail = 0;
void *buf = (void*)TSIOBufferBlockWriteStart(iobuf_blk, &bytes_avail);
ink_release_assert(bytes_avail == (8 << indx));
// use buf as a normal malloced ptr up to (8 << indx) bytes.
// When done clean up:
TSIOBufferDestroy(iobuf);
{code}

Obviously this could be done in such a way using (macros?) such that it's all 
hidden from the user. Or I'm open to a light wrapper around it, but we more or 
less have what we need already...


was (Author: briang):
Guys the more i've been thinking about this I wonder if we can't just use 
exiting APIs to accomplish exactly this:

{code}
TSIOBuffer iobuf_1mb = TSIOBufferSizedCreate(indx);
TSIOBufferBlock iobuf_blk = TSIOBufferStart(iobuf_1mb);
int64_t bytes_avail = 0;
void *buf = (void*)TSIOBufferBlockWriteStart(iobuf_blk, &bytes_avail);
ink_release_assert(bytes_avail == (8 << indx));
// use buf as a normal malloced ptr up to (8 << indx) bytes.
// When done clean up:
TSIOBufferDestroy(iobuf_1mb);
{code}

Obviously this could be done in such a way using (macros?) such that it's all 
hidden from the user. Or I'm open to a light wrapper around it, but we more or 
less have what we need already...

> Add / modify APIs to allow easy freelist allocation of iobuffer's from C/C++ 
> plugins
> ------------------------------------------------------------------------------------
>
>                 Key: TS-2581
>                 URL: https://issues.apache.org/jira/browse/TS-2581
>             Project: Traffic Server
>          Issue Type: New Feature
>          Components: TS API
>            Reporter: Leif Hedstrom
>            Assignee: Brian Geffon
>              Labels: api-addition
>             Fix For: 6.0.0
>
>
> This would allow for efficient allocations in plugins, such that they can do 
> an in-place new() on a chunk of memory (iobuffer). 
> The API / features should make it easy and possible to asks for an iobuffer 
> of at least size <x>. It can return a bigger one, at which point, you'd waste 
> some. But this allows us to reuse / repurpose the existing iobuffer 
> allocation.
> Phil points out that there are existing iobuffer allocation APIs, so maybe 
> something in conjunction with that is appropriate. I would like for this to 
> be easy on the plugin user though, such that it's as simple as "malloc/free" 
> chains.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to