So i have a function that allocates a part of memory, then fills it with data and then returns it. i also want to free this allocated memory but if i free it before return it will return null, also if i try to free after return, since function ends when it see return, it won't free the memo. So i asked a couple friends one of them said there is a syntax that returns the data and free it at the same time. Tho i couldn't find anything about it in the net and i need help.
i tried some braindead attemptions like return (free(x)); and return ((x)free); ??? but obviusly they didn't work.