The data is obtained from the source argument, see zip_source3.
NOTE zip_source_free3 should not be called on a source after it was used successfully in a zip_file_add or zip_file_replace call.
zip_source_t *s; const char *buf="teststring"; if ((s=zip_source_buffer(archive, buf, sizeof(buf), 0)) == NULL || zip_file_add(archive, name, s, ZIP_FL_ENC_UTF_8) < 0) { zip_source_free(s); printf("error adding file: %s\n", zip_strerror(archive)); }