# Documentation of buf struct

**URL:** <https://www.ruby-forum.com/t/documentation-of-buf-struct/242502>\
**Category:** NGINX\
**Created:** [June 28, 2015, 5:13pm UTC](https://www.ruby-forum.com/t/documentation-of-buf-struct/242502 "2015-06-28T17:13:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 28, 2015, 5:13pm UTC](https://www.ruby-forum.com/t/documentation-of-buf-struct/242502/1 "2015-06-28T17:13:20Z")

</div>

I am not very clear on the purpose of different data members within the  
buf structure.(appended below)

After looking through the code, I can figure out the purpose of

- pos,last (sliding window)

- file\_pos, file\_last, start, end ,(data start and end)

- tag, (which module owns this buf)

- file (name of the file if any associated with the data)

- memory(cannot be released by any module that processes the buf).

- mmap (buf is memory map)

- last\_in\_chain(last in the chain of bufs)

- last\_buf(last in the response)

- For temporary: can the temporary buffer be released by any module  
that processes it or can it be released by only the module that owns it  
as indicated in the tag

It will be good if the purpose of other data members is described also.  
Thanks for any inputs

struct ngx\_buf\_s { u\_char \*pos; u\_char \*last;  
off\_t file\_pos; off\_t file\_last;  
u\_char _start; /_ start of buffer \*/ u\_char  
_end; /_ end of buffer \*/ ngx\_buf\_tag\_t tag;  
ngx\_file\_t \*file; ngx\_buf\_t \*shadow;

```
/* the buf's content could be changed */ unsigned         

```

temporary:1;  
/\* \* the buf’s content is in a memory cache or in a read only  
memory \* and must not be changed _/ unsigned  
memory:1;  
/_ the buf’s content is mmap()ed and must not be changed _/  
unsigned mmap:1;  
unsigned recycled:1; unsigned in\_file:1;  
unsigned flush:1; unsigned sync:1; unsigned  
last\_buf:1; unsigned last\_in\_chain:1;  
unsigned last\_shadow:1; unsigned temp\_file:1;  
/_ STUB \*/ int num;};
