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);
379 struct magic_map *map;
389 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
390 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
391 file_oomem(ms, sizeof(*map));
473 if (map->magic[j])
474 - free(map->magic[j]);
475 + efree(map->magic[j]);
477 - free(map);
478 + efree(map);
481 return map;
569 struct magic_map *map;
575 - if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
579 + if ((map = CAST(struct magic_map *, ecalloc(1, sizeof(*map)))) == NULL) {
580 file_oomem(ms, sizeof(*map));
581 + efree(map);
586 + map->p = (void *)&php_magic_database;
627 - map->len = (size_t)st.st_size;
629 - if ((map->p = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
631 - file_error(ms, errno, "cannot map `%s'", dbname);
635 - if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
636 + map->len = (size_t)st.sb.st_size;
637 + if ((map->p = CAST(void *, emalloc(map->len))) == NULL) {
638 file_oomem(ms, map->len);
641 - if (read(fd, map->p, map->len) != (ssize_t)map->len) {
642 + if (php_stream_read(stream, map->p, (size_t)st.sb.st_size) != (size_t)st.sb.st_size) {
646 map->len = 0;
651 - ptr = CAST(uint32_t *, map->p);
657 + ptr = (uint32_t *)(void *)map->p;
683 + map->p = emalloc(sizeof(php_magic_database));
684 + map->p = memcpy(map->p, php_magic_database, sizeof(php_magic_database));
697 map->magic[0] = CAST(struct magic *, map->p) + 1;
700 map->magic[i + 1] = map->magic[i] + map->nmagic[i];
701 nentries += map->nmagic[i];
712 byteswap(map->magic[i], map->nmagic[i]);
718 return map;
726 apprentice_unmap(map);
765 - if (write(fd, map->nmagic, nm) != (ssize_t)nm) {
766 + if (php_stream_write(stream, (const char *)map->nmagic, nm) != (ssize_t)nm) {
780 len = m * map->nmagic[i];
781 - if (write(fd, map->magic[i], len) != (ssize_t)len) {
782 + if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) {
1423 void *map; /* internal resources used by entry */