Thread: Error when realloc in C

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    Quote Originally Posted by thachdovan View Post
    In this case, how I can free the pointer.
    Thank you so much!
    You can only free what you allocated with malloc. In the above code 'p_array' looks like a global variable or something which means you don't have to free it.

    Quote Originally Posted by thachdovan View Post
    Finally, It worked, but I have a question. Should I use DMA in runtime application and in a small memory device?
    Thank you so much!
    What do you mean by DMA ? I take this to mean Direct Memory Access which is irrelevant here.

  2. #2
    Registered User
    Join Date
    Jul 2016
    Posts
    17
    Quote Originally Posted by Aslaville View Post
    What do you mean by DMA ? I take this to mean Direct Memory Access which is irrelevant here.
    Of course, Dynamic memory allocation, Thank you.

  3. #3
    Registered User
    Join Date
    Jul 2016
    Posts
    17
    Quote Originally Posted by Aslaville View Post
    You can only free what you allocated with malloc. In the above code 'p_array' looks like a global variable or something which means you don't have to free it.
    In above code, I init p_array with malloc, so I need to free it. why in this case, I dont have to free it. Please share in more detail. Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 02-13-2013, 11:35 AM
  2. Error using realloc inside function
    By NotAProgrammer in forum C Programming
    Replies: 10
    Last Post: 12-29-2012, 08:13 AM
  3. Replies: 3
    Last Post: 08-22-2008, 11:12 AM
  4. Error when freeing memory (allocated with realloc)
    By svdrjeug in forum C Programming
    Replies: 18
    Last Post: 01-03-2008, 11:16 AM
  5. use of realloc
    By alzar in forum C Programming
    Replies: 3
    Last Post: 09-17-2007, 12:18 PM

Tags for this Thread