User Profile
Collapse
-
Thank you for the answer. I do appreciate it. Its crazy how I couldn't find a simple explanation online. Obviously its out there, I just didn't have the right search parameters. Thanks again. -
Wait, timeout. I think I know what I overlooked here. Since headerstr gets assigned to newheaderstr at one point, it eventually does get freed. So I'm assuming that when malloc is called again for newheaderstr, it must get reassigned to a new memory address. While headerstr is still pointing to the old one. Good, I don't think theres a memory leak here. Although, if you see one let me know. I'd like to know if there's any buffer overflows.Leave a comment:
-
Multiple Malloc Calls on one Variable
I'd like to know what happens if I use multiple calls to malloc() on one pointer (without free) in a single function. Here is the example:
...Code:void *data_thread(void *sockfd_ptr) { int sockfd = *(int *) sockfd_ptr; const int BUFSIZE = 5; char recvmessage[BUFSIZE]; char *headerstr = NULL; char *newheaderstr = NULL; int recvbytes = 0; int curheadlen = 0; int totalheadlen
No activity results to display
Show More
Leave a comment: