User Profile

Collapse

Profile Sidebar

Collapse
tech1544
tech1544
Last Activity: Sep 13 '13, 12:46 PM
Joined: Feb 13 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • tech1544
    replied to Multiple Malloc Calls on one Variable
    in C
    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.
    See more | Go to post

    Leave a comment:


  • tech1544
    replied to Multiple Malloc Calls on one Variable
    in C
    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.
    See more | Go to post

    Leave a comment:


  • tech1544
    started a topic Multiple Malloc Calls on one Variable
    in C

    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
    ...
    See more | Go to post
    Last edited by Rabbit; Feb 13 '13, 10:06 PM. Reason: Please use code tags when posting code.
No activity results to display
Show More
Working...