[Solved] Error when coding my own implementation of realloc()

Invalid assumption: void *my_realloc(void *ptr, size_t size) { unsigned char *old_ptr = (unsigned char *)ptr; You’re breaking the realloc() specification here. realloc() doesn’t assume that the ptr would always be pointing to a string. It is type-agnostic. And the cast is redundant. There’s an implicit conversion from void * to any other pointer type. Undefined … Read more

[Solved] Valgrind getting strange error

First of all and most importantly: This is not good C++ code, not even decent. For example, some of your #includes are wrong, like <stdio.h> should be <cstdio> instead. The worst thing here are those #defines that make your code utterly unreadable. You really should read a good book on C++! For better readability I … Read more

[Solved] Why is this segfaulting? Can someone explain the valgrind error?

Valgrind says that the illegal write is occurring at Address 0x6172676f72502074. If you look at that address as ASCII characters, it’s: argorP t, or converting from little endian: t Progra. This looks like part of one of your menu items, “9. Abort Program”. Maybe the bug is that menu_init() is writing past the end of … Read more

[Solved] Valgrind detects memory leak, can’t find it C

Your initDictionary doesn’t return the pointer dictionary anywhere. That means when you do Dictionary* dictionary = initDictionary(); the value of dictionary will be indeterminate (seemingly random or garbage), and dereferencing this pointer or passing it to free will result in undefined behavior. You solve this by adding a simple return dictionary; at the end of … Read more

[Solved] Invalid read of size – C valgrind

Here after is a proposed solution in main() : List of the corrected errors and enhancements: 1- in the formatting output, replace %p (dedicated to pointers) by %s (dedicated to strings). 2- before storing in the output string zeile_array[d] allocate it to the len of the output text zeile including the null-terminator. 3- instead of … Read more

[Solved] connection refused when I want to telnet my Ubuntu ip

There are many possible reasons, but four come immediately to mind. The IP address is invalid. The IP address is unreachable because of an error in routing table configuration on intermediate nodes. A firewall somewhere is refusing to admit the traffic. The target host has inetd so configured as not to accept inbound telnet requests. … Read more