Simplify fstk_FindFile usage (#1310)

* Simplify `fstk_FindFile` usage

* Use `std::string` for `fstk_FindFile`
This commit is contained in:
Sylvie
2024-02-22 07:14:38 -05:00
committed by GitHub
parent c70cecc24a
commit 6d29d2a67e
3 changed files with 33 additions and 69 deletions

View File

@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include "asm/fstack.hpp"
@@ -807,13 +808,10 @@ void sect_BinaryFile(char const *s, int32_t startPos)
if (!checkcodesection())
return;
char *fullPath = NULL;
size_t size = 0;
FILE *f = NULL;
std::string *fullPath = fstk_FindFile(s);
FILE *f = fullPath ? fopen(fullPath->c_str(), "rb") : NULL;
if (fstk_FindFile(s, &fullPath, &size))
f = fopen(fullPath, "rb");
free(fullPath);
delete fullPath;
if (!f) {
if (generatedMissingIncludes) {
@@ -881,13 +879,10 @@ void sect_BinaryFileSlice(char const *s, int32_t start_pos, int32_t length)
if (!reserveSpace(length))
return;
char *fullPath = NULL;
size_t size = 0;
FILE *f = NULL;
std::string *fullPath = fstk_FindFile(s);
FILE *f = fullPath ? fopen(fullPath->c_str(), "rb") : NULL;
if (fstk_FindFile(s, &fullPath, &size))
f = fopen(fullPath, "rb");
free(fullPath);
delete fullPath;
if (!f) {
if (generatedMissingIncludes) {