Category : memory-management

I was trying to solve Leetcode problem 24: "swapping nodes in Pairs" and tried to store all values of list to an array and then swap the elements of array and then create a new list while deleting old one. But doing so is resulting in this error : > ================================================================= ==31==ERROR: AddressSanitizer: heap-use-after-free on ..

Read more

I have taken the string replace algorithm from here. Then I modified it to use safer function where ever possible. But it looks like my implementation has some bug, because when I free the memory it gives HEAP CORRUPTION DETECTED. My Code: #include <stdio.h> #include <stdlib.h> #include <string.h> char* str_replace(char* orig, char* rep, char* with) ..

Read more