Lines Matching refs:map
117 mlp->map = idx == 0 ? map : NULL;
122 ml->map = NULL;
126 struct magic_map *map;
135 return apprentice_compile(ms, map, fn);
139 map = apprentice_map(ms, fn);
140 if (map == NULL) {
143 - map = apprentice_load(ms, fn, action);
147 + map = apprentice_load(ms, fn, action);
149 if (map == NULL)
154 if (add_mlist(ms->mlist[i], map, i) == -1) {
157 + apprentice_unmap(map);
228 if (map == NULL)
231 - switch (map->type) {
234 - if (map->p)
235 - (void)munmap(map->p, map->len);
239 - free(map->p);
245 + if (map->p != php_magic_database) {
246 + if (map->p == NULL) {
249 + if (map->magic[j]) {
250 + efree(map->magic[j]);
254 + efree(map->p);
257 - free(map);
258 + efree(map);
272 if (ml->map)
273 apprentice_unmap(ml->map);
289 - struct magic_map *map;
308 - map = apprentice_buf(ms, bufs[i], sizes[i]);
309 - if (map == NULL)
313 - if (add_mlist(ms->mlist[j], map, j) == -1) {
463 struct magic_map *map;
475 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL)
476 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL)
478 file_oomem(ms, sizeof(*map));
656 struct magic_map *map;
662 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
665 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
666 file_oomem(ms, sizeof(*map));
672 + map->p = (void *)&php_magic_database;
710 - map->len = (size_t)st.st_size;
712 - if ((map->p = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
714 - file_error(ms, errno, "cannot map `%s'", dbname);
717 - map->type = MAP_TYPE_MMAP;
719 - if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
720 + map->len = (size_t)st.sb.st_size;
721 + if ((map->p = CAST(void *, emalloc(map->len))) == NULL) {
722 file_oomem(ms, map->len);
725 - if (read(fd, map->p, map->len) != (ssize_t)map->len) {
726 + if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
730 - map->type = MAP_TYPE_MALLOC;
731 + map->len = 0;
737 - if (check_buffer(ms, map, dbname) != 0)
742 + ptr = (uint32_t *)(void *)map->p;
767 + map->p = emalloc(sizeof(php_magic_database));
768 + map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database));
781 + map->magic[0] = CAST(struct magic *, map->p) + 1;
785 + map->nmagic[i] = swap4(ptr[i + 2]);
787 + map->nmagic[i] = ptr[i + 2];
789 + map->magic[i + 1] = map->magic[i] + map->nmagic[i];
790 + nentries += map->nmagic[i];
799 + byteswap(map->magic[i], map->nmagic[i]);
804 return map;
812 apprentice_unmap(map);
831 static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS;
832 static const size_t m = sizeof(**map->magic);
862 memcpy(hdr.h + 2, map->nmagic, nm);
871 len = m * map->nmagic[i];
872 - if (write(fd, map->magic[i], len) != (ssize_t)len) {
873 + if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) {