MCPcopy Create free account
hub / github.com/antirez/ds4 / parse_metadata

Function parse_metadata

ds4.c:1859–1885  ·  view source on GitHub ↗

Read the GGUF metadata table. Values stay in the mmap; we store offsets so * later validation can decode only the keys it needs. */

Source from the content-addressed store, hash-verified

1857static bool write_f32_binary_file(const char *path, const float *data, uint64_t n) {
1858 FILE *fp = fopen(path, "wb");
1859 if (!fp) {
1860 fprintf(stderr, "ds4: failed to open %s for writing: %s\n", path, strerror(errno));
1861 return false;
1862 }
1863 const size_t nw = fwrite(data, sizeof(float), (size_t)n, fp);
1864 const bool ok = nw == (size_t)n && fclose(fp) == 0;
1865 if (!ok) {
1866 fprintf(stderr, "ds4: failed to write %s\n", path);
1867 return false;
1868 }
1869 return true;
1870}
1871
1872static bool read_f32_binary_file(const char *path, float *data, uint64_t n) {
1873 struct stat st;
1874 if (stat(path, &st) != 0) {
1875 fprintf(stderr, "ds4: failed to stat %s: %s\n", path, strerror(errno));
1876 return false;
1877 }
1878 if (st.st_size < 0 || (uint64_t)st.st_size != n * sizeof(float)) {
1879 fprintf(stderr,
1880 "ds4: %s has size %llu bytes, expected %llu bytes\n",
1881 path,
1882 (unsigned long long)st.st_size,
1883 (unsigned long long)(n * sizeof(float)));
1884 return false;
1885 }
1886
1887 FILE *fp = fopen(path, "rb");
1888 if (!fp) {

Callers 1

model_openFunction · 0.85

Calls 6

ds4_dieFunction · 0.85
cursor_stringFunction · 0.85
cursor_u32Function · 0.85
ds4_streqFunction · 0.85
cursor_atFunction · 0.85
skip_valueFunction · 0.85

Tested by

no test coverage detected