---
name: "zip_source_buffer"
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"
---

# zip\_source\_buffer(3)

create zip data source from buffer

## NAME

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

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

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

**zip\_source\_buffer**(*zip\_t \*archive*, *const void \*data*, *zip\_uint64\_t len*, *int freep*);

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

**zip\_source\_buffer\_create**(*const void \*data*, *zip\_uint64\_t len*, *int freep*, *zip\_error\_t \*error*);

## DESCRIPTION

The functions **zip\_source\_buffer**() and **zip\_source\_buffer\_create**() create a zip source from the buffer *data* of size *len*. If *freep* is non-zero, the buffer will be freed when it is no longer needed. *data* must remain valid for the lifetime of the created source.

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\]

  *len* is greater than zero and *data* 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**() and **zip\_source\_buffer\_create**() were added in libzip 1.0.

## AUTHORS

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