Is there a linux equivalent of _aligned_realloc? I want to use realloc so I don’t have to memcpy the data every time I resize it. Am I stuck with mmap? I only used mmap once is there a recommended way of implementing memory that will be resized a few times? I’m assuming I can’t mix mmap with aligned_alloc and I
Tag: realloc
C realloc assertion
Not sure why I’m getting the following error when trying to use realloc: malloc.c:2401: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize – 1)) == 0)’ failed. Aborted (core dumped) Here is the code fragment Answer In your loop, you check for nstructs
Reuse char * pointer needs to free and malloc again?
I would like to implement a main function such as in order to execute system commands. The following code is currently used : Because I need to enter other commands, I am currently using the same cmd_buffer by using free() before reallocating memory. Is it the right way to do ? Some other commands might be required in the future.
Why are the values in my dynamic 2D char array being overwritten?
I’m trying to build a process logger in C on Linux, but having trouble getting it right. I’d like it to have 3 colums: USER, PID, COMMAND. I’m using the output of ps aux and trying to dynamically append it to an array. That is, for every line ps aux outputs, I want to add a row to my array.