# Function chunk related functions

```
// Get a function chunk attribute
//       ea     - any address in the chunk
//       attr   - one of: FUNCATTR_START, FUNCATTR_END
//                        FUNCATTR_OWNER, FUNCATTR_REFQTY
// returns: desired attribute or -1

long get_fchunk_attr(long ea, long attr);

// Set a function chunk attribute
//       ea     - any address in the chunk
//       attr   - nothing defined yet
//       value  - desired bg color (RGB)
// returns: 0 if failed, 1 if success

success set_fchunk_attr(long ea, long attr, long value);

// Get a function chunk referer
//       ea     - any address in the chunk
//       idx    - referer index (0..get_fchunk_attr(FUNCATTR_REFQTY))
// returns: referer address or BADADDR

long get_fchunk_referer(long ea, long idx);

// Get next function chunk
//       ea     - any address
// returns: the starting address of the next
//          function chunk or BADADDR
// This function enumerates all chunks of all functions in the database

long get_next_fchunk(long ea);

// Get previous function chunk
//       ea     - any address
// returns: the starting address of the previous
//          function chunk or BADADDR
// This function enumerates all chunks of all functions in the database

long get_prev_fchunk(long ea);

// Append a function chunk to the function
//       funcea   - any address in the function
//       ea1, ea2 - boundaries of a function tail to add.
//                  If a chunk exists at the specified addresses,
//                  it must have exactly the specified boundaries
// returns: 0 if failed, 1 if success

success append_func_tail(long funcea, long ea1, long ea2);

// Remove a function chunk from the function
//       funcea - any address in the function
//       ea1    - any address in the function chunk to remove
// returns: 0 if failed, 1 if success

success remove_fchunk(long funcea, long tailea);

// Change the function chunk owner
//       tailea - any address in the function chunk
//       funcea - the starting address of the new owner
// returns: 0 if failed, 1 if success
// The new owner must already have the chunk appended before the call

success set_tail_owner(long tailea, long funcea);

// Get the first function chunk of the specified function
//       funcea - any address in the function
// returns: the function entry point or BADADDR
// This function returns the first (main) chunk of the specified function

long first_func_chunk(long funcea);

// Get the next function chunk of the specified function
//         arguments:      funcea - any address in the function
//                         tailea - any address in the current chunk
//         returns:        the starting address of the next
//                         function chunk or BADADDR
// This function returns the next chunk of the specified function

long next_func_chunk(long funcea, long tailea);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/8.4/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/1077.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
