A question about dynamic memory allocation 2

After a few years, I discovered a memory leak bug in my code. Unfortunately the bug was not causing any issues to be noticed until i found out about it indirectly. If you want to know more asked a question about it here: https://stackoverflow.com/?newreg=4b839ccb32864d4ca199e32714120a10 bellow there is a function addElement from a class c_string that… Read More A question about dynamic memory allocation 2

How to convert lifetime of boxed reference without allocating a new box?

Context Playground, This works: fn get_owned_box_working<‘a>(b: Box<&’a i32>) -> Box<&’static i32> { Box::new(&42) } but this doesn’t: fn get_owned_box_broken<‘a>(b: Box<&’a i32>) -> Box<&’static i32> { *b = &42; b } error[E0308]: mismatched types –> src/lib.rs:3:5 | 3 | b | ^ lifetime mismatch | = note: expected struct `Box<&’static i32>` found struct `Box<&’a i32>` note:… Read More How to convert lifetime of boxed reference without allocating a new box?

C++ Can not manage to display the class datatype array

This is the code I wrote, total beginner #include <iostream> #include <cstring> using namespace std; class Person { public: string ID; string name; string surname; string department; string email; public: //get and set functions for ID, Name, Surname, Department, Email properties string getID() { return this->ID; }; void setID(string _ID) { this->ID = _ID; };… Read More C++ Can not manage to display the class datatype array

Valgrind message: Conditional jump or move depends on uninitialised value(s) unresolved

i’m trying a new assignment i’ve got: i need to copy the Environment variables from the shell into an array, then lowercase them and print them back. (i’m using Ubuntu 20.04.4 LTS, gcc for compiling, and writing my code in C language). i was adviced to use malloc to create the array but decided not… Read More Valgrind message: Conditional jump or move depends on uninitialised value(s) unresolved

Class X cannot be cast to class Boolean (X is in unnamed module of loader 'app'; Boolean is in module java.base of loader 'bootstrap

I noticed that when others are getting this problem, it is because they are trying to cast objects. I am not trying to cast. Furthermore, I am trying to ask if an object exists in a data table using Spring Boot repository. The following issue is occurring: What is the issue exactly? The model: @Entity… Read More Class X cannot be cast to class Boolean (X is in unnamed module of loader 'app'; Boolean is in module java.base of loader 'bootstrap

C++ Segmentation fault when changing (int32_t *) pointer within method call

I’m programming a server – client application with a shared utils.cpp. So the server and client use the (in utils.h) predefined methods: int listening_socket(int port); int connect_socket(const char *hostname, const int port); int accept_connection(int sockfd); int recv_msg(int sockfd, int32_t *operation_type, int64_t *argument); int send_msg(int sockfd, int32_t *operation_type, int64_t *argument); So far, so good. But since… Read More C++ Segmentation fault when changing (int32_t *) pointer within method call