Skip to content

Cant make empty process variable #281

@thesstraight

Description

@thesstraight

so i have tried doing this using libmem.hpp in c++ 20

libmem::Process process{};

but when compiling with g++ i get error

error: no matching function for call to ‘libmem::Process::Process(<brace-enclosed initializer list>)’
   24 |     libmem::Process process{};

i added Process(){}; before Process(const struct lm_process_t *process);
now i can do this

new code

libmem::Process process{};

    {   
        std::optional<libmem::Process> getProcess{ libmem::FindProcess(::processName.data()) };

        if (!getProcess.has_value())
        {
            std::cerr << "process not found\n";

            return 1;
        }

        process = getProcess.value();
    }

and saves me from doing this

previous code

    std::optional<libmem::Process> getProcess{ libmem::FindProcess(::processName.data()) };

    if (!getProcess.has_value())
    {
        std::cerr << "process not found\n";

        return 1;
    }

    const libmem::Process process(getProcess.value());

what do you think? new code should save some memory if i am correct, is my usage of ur library wrong?
i know i can call getProcess.value() and have 1 variable but calling getProcess.value() on every function that uses libmem::Process can have impact

edit: ill stick to previous code, im not sure if changing the struct may give memory leaks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions