---
name: "zip_source_buffer_fragment"
section: "3"
platform: "linux"
package: "libzip"
version: "1.11.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/zip_source_buffer_fragment"
---

# zip\_source\_buffer\_fragment(3)

create zip data source from multiple buffer

## NAME

**zip\_source\_buffer\_fragment**, **zip\_source\_buffer\_fragment\_create** – create zip data source from multiple buffer

## LIBRARY

libzip (-lzip)

## SYNOPSIS

**#include \<zip.h\>**

*zip\_source\_t* *\**\

**zip\_source\_buffer\_fragment**(*zip\_t \*archive*, *zip\_buffer\_fragment\_t \*fragments*, *zip\_uint64\_t nfragments*, *int freep*);

*zip\_source\_t* *\**\

**zip\_source\_buffer\_fragment\_create**(*zip\_buffer\_fragment\_t \*fragments*, *zip\_uint64\_t nfragments*, *int freep*, *zip\_error\_t \*error*);

## DESCRIPTION

The functions **zip\_source\_buffer\_fragment**() and **zip\_source\_buffer\_fragment\_create**() create a zip source from the data in *fragments*. *nfragments* specifies the number of fragments. If *freep* is non-zero, the data will be freed when it is no longer needed.

```
struct zip_stat {
    zip_uint8_t *data;    /* pointer to the actual data */
    zip_uint64_t length;  /* length of this fragment */
};
```

The data *fragments* point to must remain valid for the lifetime of the created source. *fragments* itself can be discarded once the source is created.

The source can be used to open a zip archive from.

## RETURN VALUES

Upon successful completion, the created source is returned. Otherwise, NULL is returned and the error code in *archive* or *error* is set to indicate the error.

## ERRORS

**zip\_source\_buffer**() and **zip\_source\_buffer\_create**() fail if:

- \[ZIP\_ER\_INVAL\]

  *nfragments* is greater than zero and *fragments* is NULL.

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_file\_add(3)](/zip_file_add/3.md), [zip\_file\_replace(3)](/zip_file_replace/3.md), [zip\_open\_from\_source(3)](/zip_open_from_source/3.md), [zip\_source(5)](/zip_source/5.md)

## HISTORY

**zip\_source\_buffer\_fragment**() and **zip\_source\_buffer\_fragment\_create**() were added in libzip 1.4.0.

## AUTHORS

Dieter Baron ⟨*dillo@nih.at*⟩ and Thomas Klausner ⟨*wiz@gatalith.at*⟩
