Lines Matching refs:map

142  	mlp->map = NULL;
147 ml->map = idx == 0 ? map : NULL;
151 struct magic_map *map;
160 return apprentice_compile(ms, map, fn);
164 map = apprentice_map(ms, fn);
165 if (map == (struct magic_map *)-1)
167 if (map == NULL) {
170 - map = apprentice_load(ms, fn, action);
174 + map = apprentice_load(ms, fn, action);
176 if (map == NULL)
238 apprentice_unmap(struct magic_map *map)
241 if (map == NULL)
244 - switch (map->type) {
249 - void *b = map->magic[i];
250 - void *p = map->p;
252 - CAST(char *, b) <= CAST(char *, p) + map->len)
254 - free(map->magic[i]);
255 + if (map->p != php_magic_database) {
256 + if (map->p == NULL) {
259 + if (map->magic[j]) {
260 + efree(map->magic[j]);
264 + efree(map->p);
266 - free(map->p);
270 - if (map->p && map->p != MAP_FAILED)
271 - (void)munmap(map->p, map->len);
277 - free(map);
278 + efree(map);
292 if (ml->map)
293 apprentice_unmap(CAST(struct magic_map *, ml->map));
309 - struct magic_map *map;
327 - map = apprentice_buf(ms, bufs[i], sizes[i]);
328 - if (map == NULL)
332 - if (add_mlist(ms->mlist[j], map, j) == -1) {
522 struct magic_map *map;
534 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL)
535 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL)
537 file_oomem(ms, sizeof(*map));
907 struct magic_map *map;
909 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
910 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
911 file_oomem(ms, sizeof(*map));
924 struct magic_map *map;
933 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
934 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
935 file_oomem(ms, sizeof(*map));
941 + map->p = (void *)&php_magic_database;
944 - map->type = MAP_TYPE_USER; /* unspecified */
980 - map->len = (size_t)st.st_size;
982 - map->type = MAP_TYPE_MMAP;
983 - if ((map->p = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
985 - file_error(ms, errno, "cannot map `%s'", dbname);
989 - map->type = MAP_TYPE_MALLOC;
990 - if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
991 + map->len = (size_t)st.sb.st_size;
992 + if ((map->p = CAST(void *, emalloc(map->len))) == NULL) {
993 file_oomem(ms, map->len);
996 - if (read(fd, map->p, map->len) != (ssize_t)map->len) {
997 + if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
1001 + map->len = 0;
1007 - if (check_buffer(ms, map, dbname) != 0) {
1013 + ptr = (uint32_t *)(void *)map->p;
1033 - if (mprotect(map->p, (size_t)st.st_size, PROT_READ) == -1) {
1040 + map->p = emalloc(sizeof(php_magic_database));
1041 + map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database));
1054 + map->magic[0] = CAST(struct magic *, map->p) + 1;
1058 + map->nmagic[i] = swap4(ptr[i + 2]);
1060 + map->nmagic[i] = ptr[i + 2];
1062 + map->magic[i + 1] = map->magic[i] + map->nmagic[i];
1063 + nentries += map->nmagic[i];
1073 + byteswap(map->magic[i], map->nmagic[i]);
1079 return map;
1087 apprentice_unmap(map);
1108 static const size_t nm = sizeof(*map->nmagic) * MAGIC_SETS;
1109 static const size_t m = sizeof(**map->magic);
1137 memcpy(hdr.h + 2, map->nmagic, nm);
1147 len = m * map->nmagic[i];
1148 - if (write(fd, map->magic[i], len) != (ssize_t)len) {
1149 + if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) {
1164 - apprentice_unmap(map);