Lines Matching refs:map
108 ml->map = idx == 0 ? map : NULL;
110 return apprentice_compile(ms, map, fn);
114 map = apprentice_map(ms, fn);
115 if (map == NULL) {
118 - map = apprentice_load(ms, fn, action);
122 + map = apprentice_load(ms, fn, action);
124 if (map == NULL)
185 if (map == NULL)
187 - if (map->p == NULL)
190 - if (map->len)
191 - (void)munmap(map->p, map->len);
194 - free(map->p);
195 - free(map);
196 + if (map->p != php_magic_database) {
197 + if (map->p == NULL) {
200 + if (map->magic[j]) {
201 + efree(map->magic[j]);
205 + efree(map->p);
208 + efree(map);
222 if (ml->map)
223 apprentice_unmap(ml->map);
362 struct magic_map *map;
375 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL)
376 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL)
378 file_oomem(ms, sizeof(*map));
447 if (map->magic[j])
448 - free(map->magic[j]);
449 + efree(map->magic[j]);
451 - free(map);
452 + efree(map);
455 return map;
543 struct magic_map *map;
549 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
553 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
554 file_oomem(ms, sizeof(*map));
560 + map->p = (void *)&php_magic_database;
597 - map->len = (size_t)st.st_size;
599 - if ((map->p = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
601 - file_error(ms, errno, "cannot map `%s'", dbname);
605 - if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
606 + map->len = (size_t)st.sb.st_size;
607 + if ((map->p = CAST(void *, emalloc(map->len))) == NULL) {
608 file_oomem(ms, map->len);
611 - if (read(fd, map->p, map->len) != (ssize_t)map->len) {
612 + if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
616 map->len = 0;
621 - ptr = CAST(uint32_t *, map->p);
627 + ptr = (uint32_t *)(void *)map->p;
653 + map->p = emalloc(sizeof(php_magic_database));
654 + map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database));
667 map->magic[0] = CAST(struct magic *, map->p) + 1;
670 map->magic[i + 1] = map->magic[i] + map->nmagic[i];
671 nentries += map->nmagic[i];
682 byteswap(map->magic[i], map->nmagic[i]);
688 return map;
696 apprentice_unmap(map);
731 - if (write(fd, map->nmagic, nm) != (ssize_t)nm) {
732 + if (php_stream_write(stream, (const char *)map->nmagic, nm) != (ssize_t)nm) {
746 len = m * map->nmagic[i];
747 - if (write(fd, map->magic[i], len) != (ssize_t)len) {
748 + if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) {