case KEYPRESS(0, CHAR_CARRIAGE_RETURN, 0): /* EZpad Mini 4s firmware sends malformed events */
case KEYPRESS(0, CHAR_CARRIAGE_RETURN, CHAR_CARRIAGE_RETURN): /* Teclast X98+ II firmware sends malformed events */
if (!streq16(line, *line_in)) {
- FreePool(*line_in);
+ free(*line_in);
*line_in = TAKE_PTR(line);
}
return TRUE;
}
if (timeout_remain > 0) {
- FreePool(status);
+ free(status);
status = xpool_print(L"Boot in %u s.", timeout_remain);
}
case KEYPRESS(0, 0, 'd'):
case KEYPRESS(0, 0, 'D'):
if (config->idx_default_efivar != idx_highlight) {
- FreePool(config->entry_default_efivar);
+ free(config->entry_default_efivar);
config->entry_default_efivar = xstrdup16(config->entries[idx_highlight]->id);
config->idx_default_efivar = idx_highlight;
status = xstrdup16(u"Default boot entry selected.");
assert(config->entry_count < IDX_MAX);
if ((config->entry_count & 15) == 0) {
- UINTN i = config->entry_count + 16;
- config->entries = xreallocate_pool(
+ config->entries = xrealloc(
config->entries,
sizeof(void *) * config->entry_count,
- sizeof(void *) * i);
+ sizeof(void *) * (config->entry_count + 16));
}
config->entries[config->entry_count++] = entry;
}
if (!entry)
return;
- FreePool(entry->id);
- FreePool(entry->title_show);
- FreePool(entry->title);
- FreePool(entry->sort_key);
- FreePool(entry->version);
- FreePool(entry->machine_id);
- FreePool(entry->loader);
- FreePool(entry->devicetree);
- FreePool(entry->options);
+ free(entry->id);
+ free(entry->title_show);
+ free(entry->title);
+ free(entry->sort_key);
+ free(entry->version);
+ free(entry->machine_id);
+ free(entry->loader);
+ free(entry->devicetree);
+ free(entry->options);
strv_free(entry->initrd);
- FreePool(entry->path);
- FreePool(entry->current_name);
- FreePool(entry->next_name);
- FreePool(entry);
+ free(entry->path);
+ free(entry->current_name);
+ free(entry->next_name);
+ free(entry);
}
static inline void config_entry_freep(ConfigEntry **entry) {
log_error_stall(L"Unsupported special entry identifier: %a", value);
continue;
}
- FreePool(config->entry_default_config);
+ free(config->entry_default_config);
config->entry_default_config = xstra_to_str(value);
continue;
}
/* If the file we just renamed is the loader path, then let's update that. */
if (streq16(entry->loader, old_path)) {
- FreePool(entry->loader);
+ free(entry->loader);
entry->loader = TAKE_PTR(new_path);
}
}
while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) {
if (streq8((char *) key, "title")) {
- FreePool(entry->title);
+ free(entry->title);
entry->title = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "sort-key")) {
- FreePool(entry->sort_key);
+ free(entry->sort_key);
entry->sort_key = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "version")) {
- FreePool(entry->version);
+ free(entry->version);
entry->version = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "machine-id")) {
- FreePool(entry->machine_id);
+ free(entry->machine_id);
entry->machine_id = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "linux")) {
- FreePool(entry->loader);
+ free(entry->loader);
entry->type = LOADER_LINUX;
entry->loader = xstra_to_path(value);
entry->key = 'l';
if (streq8((char *) key, "efi")) {
entry->type = LOADER_EFI;
- FreePool(entry->loader);
+ free(entry->loader);
entry->loader = xstra_to_path(value);
/* do not add an entry for ourselves */
}
if (streq8((char *) key, "devicetree")) {
- FreePool(entry->devicetree);
+ free(entry->devicetree);
entry->devicetree = xstra_to_path(value);
continue;
}
if (streq8((char *) key, "initrd")) {
- entry->initrd = xreallocate_pool(
+ entry->initrd = xrealloc(
entry->initrd,
n_initrd == 0 ? 0 : (n_initrd + 1) * sizeof(UINT16 *),
(n_initrd + 2) * sizeof(UINT16 *));
CHAR16 *s;
s = xpool_print(L"%s %s", entry->options, new);
- FreePool(entry->options);
+ free(entry->options);
entry->options = s;
} else
entry->options = TAKE_PTR(new);
/* read properties from the embedded os-release file */
while ((line = line_get_key_value(content, (CHAR8 *)"=", &pos, &key, &value))) {
if (streq8((char *) key, "PRETTY_NAME")) {
- FreePool(os_pretty_name);
+ free(os_pretty_name);
os_pretty_name = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "IMAGE_ID")) {
- FreePool(os_image_id);
+ free(os_image_id);
os_image_id = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "NAME")) {
- FreePool(os_name);
+ free(os_name);
os_name = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "ID")) {
- FreePool(os_id);
+ free(os_id);
os_id = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "IMAGE_VERSION")) {
- FreePool(os_image_version);
+ free(os_image_version);
os_image_version = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "VERSION")) {
- FreePool(os_version);
+ free(os_version);
os_version = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "VERSION_ID")) {
- FreePool(os_version_id);
+ free(os_version_id);
os_version_id = xstra_to_str(value);
continue;
}
if (streq8((char *) key, "BUILD_ID")) {
- FreePool(os_build_id);
+ free(os_build_id);
os_build_id = xstra_to_str(value);
continue;
}
UINTN new_size, read_size = info->FileSize;
if (__builtin_add_overflow(size, read_size, &new_size))
return EFI_OUT_OF_RESOURCES;
- initrd = xreallocate_pool(initrd, size, new_size);
+ initrd = xrealloc(initrd, size, new_size);
err = handle->Read(handle, &read_size, initrd + size);
if (EFI_ERROR(err))
assert(config);
for (UINTN i = 0; i < config->entry_count; i++)
config_entry_free(config->entries[i]);
- FreePool(config->entries);
- FreePool(config->entry_default_config);
- FreePool(config->entry_oneshot);
+ free(config->entries);
+ free(config->entry_default_config);
+ free(config->entry_oneshot);
}
static void config_write_entries_to_variable(Config *config) {
for (UINTN i = 0; i < config->entry_count; i++)
sz += strsize16(config->entries[i]->id);
- p = buffer = xallocate_pool(sz);
+ p = buffer = xmalloc(sz);
for (UINTN i = 0; i < config->entry_count; i++) {
UINTN l;
if (*cpio_buffer_size > UINTN_MAX - l) /* overflow check */
return EFI_OUT_OF_RESOURCES;
- a = xreallocate_pool(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
+ a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
*cpio_buffer = a;
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
if (*cpio_buffer_size > UINTN_MAX - l) /* overflow check */
return EFI_OUT_OF_RESOURCES;
- *cpio_buffer = a = xreallocate_pool(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
+ *cpio_buffer = a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
a = (CHAR8*) *cpio_buffer + *cpio_buffer_size;
memcpy(a, "070701", 6); /* magic ID */
assert(cpio_buffer_size);
assert_cc(sizeof(trailer) % 4 == 0);
- *cpio_buffer = xreallocate_pool(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + sizeof(trailer));
+ *cpio_buffer = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + sizeof(trailer));
memcpy((UINT8*) *cpio_buffer + *cpio_buffer_size, trailer, sizeof(trailer));
*cpio_buffer_size += sizeof(trailer);
return log_oom();
m = n_items + 16;
- items = xreallocate_pool(items, n_allocated * sizeof(UINT16*), m * sizeof(UINT16*));
+ items = xrealloc(items, n_allocated * sizeof(UINT16*), m * sizeof(UINT16*));
n_allocated = m;
}
}
/* Make sure a terminating NUL is available at the end */
- val = xallocate_pool(size + sizeof(CHAR16));
+ val = xmalloc(size + sizeof(CHAR16));
memcpy(val, buf, size);
val[size / sizeof(CHAR16) - 1] = 0; /* NUL terminate */
assert(name);
l = sizeof(CHAR16 *) * EFI_MAXIMUM_VARIABLE_SIZE;
- buf = xallocate_pool(l);
+ buf = xmalloc(l);
err = RT->GetVariable((CHAR16 *) name, (EFI_GUID *) vendor, NULL, &l, buf);
if (!EFI_ERROR(err)) {
/* Allocate some extra bytes to guarantee the result is NUL-terminated for CHAR8 and CHAR16 strings. */
UINTN extra = size % sizeof(CHAR16) + sizeof(CHAR16);
- buf = xallocate_pool(size + extra);
+ buf = xmalloc(size + extra);
err = handle->Read(handle, &size, buf);
if (EFI_ERROR(err))
return err;
/* A lot like LibFileInfo() but with useful error propagation */
- fi = xallocate_pool(size);
+ fi = xmalloc(size);
err = handle->GetInfo(handle, &GenericFileInfo, &size, fi);
if (err == EFI_BUFFER_TOO_SMALL) {
- FreePool(fi);
- fi = xallocate_pool(size); /* GetInfo tells us the required size, let's use that now */
+ free(fi);
+ fi = xmalloc(size); /* GetInfo tells us the required size, let's use that now */
err = handle->GetInfo(handle, &GenericFileInfo, &size, fi);
}
* file name length.
* As a side effect, most readdir_harder() calls will now be slightly faster. */
sz = sizeof(EFI_FILE_INFO) + 256 * sizeof(CHAR16);
- *buffer = xallocate_pool(sz);
+ *buffer = xmalloc(sz);
*buffer_size = sz;
} else
sz = *buffer_size;
err = handle->Read(handle, &sz, *buffer);
if (err == EFI_BUFFER_TOO_SMALL) {
- FreePool(*buffer);
- *buffer = xallocate_pool(sz);
+ free(*buffer);
+ *buffer = xmalloc(sz);
*buffer_size = sz;
err = handle->Read(handle, &sz, *buffer);
}
if (sz == 0) {
/* End of directory */
- FreePool(*buffer);
+ free(*buffer);
*buffer = NULL;
*buffer_size = 0;
}
return NULL;
for (CHAR16 **i = v; *i; i++)
- FreePool(*i);
+ free(*i);
- FreePool(v);
+ free(v);
return NULL;
}