allocate and initialize a new fmap structure */
| 252 | |
| 253 | /* allocate and initialize a new fmap structure */ |
| 254 | struct fmap *fmap_create(uint64_t base, uint32_t size, uint8_t *name) |
| 255 | { |
| 256 | struct fmap *fmap; |
| 257 | |
| 258 | fmap = malloc(sizeof(*fmap)); |
| 259 | if (!fmap) |
| 260 | return NULL; |
| 261 | |
| 262 | memset(fmap, 0, sizeof(*fmap)); |
| 263 | memcpy(&fmap->signature, FMAP_SIGNATURE, strlen(FMAP_SIGNATURE)); |
| 264 | fmap->ver_major = FMAP_VER_MAJOR; |
| 265 | fmap->ver_minor = FMAP_VER_MINOR; |
| 266 | fmap->base = htole64(base); |
| 267 | fmap->size = htole32(size); |
| 268 | memccpy(&fmap->name, name, '\0', FMAP_STRLEN); |
| 269 | |
| 270 | return fmap; |
| 271 | } |
| 272 | |
| 273 | /* free memory used by an fmap structure */ |
| 274 | void fmap_destroy(struct fmap *fmap) { |