Lines Matching refs:map
401 add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx) in add_mlist() argument
405 mlp->map = NULL; in add_mlist()
409 ml->map = idx == 0 ? map : NULL; in add_mlist()
410 ml->magic = map->magic[idx]; in add_mlist()
411 ml->nmagic = map->nmagic[idx]; in add_mlist()
426 struct magic_map *map; in apprentice_1() local
434 CAST(unsigned long, sizeof(*map->magic[0])), in apprentice_1()
440 map = apprentice_load(ms, fn, action); in apprentice_1()
441 if (map == NULL) in apprentice_1()
443 return apprentice_compile(ms, map, fn); in apprentice_1()
447 map = apprentice_map(ms, fn); in apprentice_1()
448 if (map == NULL) { in apprentice_1()
451 map = apprentice_load(ms, fn, action); in apprentice_1()
452 if (map == NULL) in apprentice_1()
457 if (add_mlist(ms->mlist[i], map, i) == -1) { in apprentice_1()
460 apprentice_unmap(map); in apprentice_1()
546 apprentice_unmap(struct magic_map *map) in apprentice_unmap() argument
548 if (map == NULL) in apprentice_unmap()
550 if (map->p != php_magic_database) { in apprentice_unmap()
551 if (map->p == NULL) { in apprentice_unmap()
554 if (map->magic[j]) { in apprentice_unmap()
555 efree(map->magic[j]); in apprentice_unmap()
559 efree(map->p); in apprentice_unmap()
562 efree(map); in apprentice_unmap()
590 if (ml->map) in mlist_free_one()
591 apprentice_unmap(CAST(struct magic_map *, ml->map)); in mlist_free_one()
1328 struct magic_map *map; in apprentice_load() local
1338 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) in apprentice_load()
1340 file_oomem(ms, sizeof(*map)); in apprentice_load()
1343 map->type = MAP_TYPE_MALLOC; in apprentice_load()
1424 &map->magic[j], &map->nmagic[j]) == -1) { in apprentice_load()
1435 apprentice_unmap(map); in apprentice_load()
1438 return map; in apprentice_load()
3038 struct magic_map *map; in apprentice_map() local
3045 if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) { in apprentice_map()
3046 file_oomem(ms, sizeof(*map)); in apprentice_map()
3051 map->p = (void *)&php_magic_database; in apprentice_map()
3087 map->type = MAP_TYPE_MALLOC; in apprentice_map()
3088 map->len = CAST(size_t, st.sb.st_size); in apprentice_map()
3089 map->p = CAST(void *, emalloc(map->len)); in apprentice_map()
3091 if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) { in apprentice_map()
3100 ptr = (uint32_t *)(void *)map->p; in apprentice_map()
3124 map->p = emalloc(sizeof(php_magic_database)); in apprentice_map()
3125 map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database)); in apprentice_map()
3138 map->magic[0] = CAST(struct magic *, map->p) + 1; in apprentice_map()
3142 map->nmagic[i] = swap4(ptr[i + 2]); in apprentice_map()
3144 map->nmagic[i] = ptr[i + 2]; in apprentice_map()
3146 map->magic[i + 1] = map->magic[i] + map->nmagic[i]; in apprentice_map()
3147 nentries += map->nmagic[i]; in apprentice_map()
3156 byteswap(map->magic[i], map->nmagic[i]); in apprentice_map()
3161 return map; in apprentice_map()
3167 apprentice_unmap(map); in apprentice_map()
3178 apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) in apprentice_compile() argument
3180 static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS; in apprentice_compile()
3181 static const size_t m = sizeof(**map->magic); in apprentice_compile()
3207 memcpy(hdr.h + 2, map->nmagic, nm); in apprentice_compile()
3215 len = m * map->nmagic[i]; in apprentice_compile()
3216 if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) { in apprentice_compile()