The tag has no usage guidance.

learn more… | top users | synonyms

1
vote
1answer
52 views

Need info on malloc trace

When I try the below code I am not clearly able to analyze malloc api internal calls.What I am not clear is about the system call mmap is called only once for 2 or more malloc calls.If I am assigning ...
3
votes
6answers
349 views

How efficient is malloc and how do implementations differ?

If I use malloc, does malloc always use the same algorithm regardless of what it is allocating or does it look at the data and select an appriopriate algorithm? Can we make malloc faster or smarter ...
2
votes
1answer
215 views

When to malloc and free?

Valgrind does not report a memory leak during my actual usage, only during my scripted test that I scripted with a shell script to test my own shell. I found that I didn't have to use malloc every ...
-1
votes
1answer
78 views

Should I add 1 to my unknown string size when I create a char array to hold it via malloc? [closed]

When I have a string of unknown size and I create an char array to hold this string. I do something like this: #define LINE_END "\r\n" int line_end_size = strlen(LINE_END); char line[]="Hello! ...
4
votes
1answer
1k views

Functions returning strings, good style?

In my C programs I often need a way to make a string representation of my ADTs. Even if I don't need to print the string to screen in any way, it is neat to have such method for debugging. So this ...
1
vote
2answers
608 views

Why don't we see (more) widespread adoption of lock-free dynamic memory allocators? [closed]

In a multithreaded programming environment, lock contention on the heap is often enough a performance bottleneck. Theoretically at least, the cream-of-the-crop solution for this problem is to have ...
-3
votes
1answer
55 views

How can this allocation of bi-dimensional arrays work? [closed]

I was seeing this post on StackOverflow and saw a new way (at least for me) to define a two dimensional array of 5x5, it works well, but I feel I don't understand what is going on in the background. ...
1
vote
3answers
222 views

Use of malloc in C [closed]

Is it necessary to call free function every time we use malloc in C. I am asking this because I have seen many times that it is not called . Thank you
1
vote
2answers
1k views

Which is better: for valid buffer length?

This is a basic question. But, I think understanding this would be helpful to play with buffers in 'C'. Thanks. Scenario Just a sample snippet char *test_buff = (char *) malloc(512); //allocate 512 ...
3
votes
2answers
2k views

How many `malloc` calls is too many? If any?

I'm implementing a system in C, implemented partially as a library. The library does most of the memory management itself, with the application layer just having to call *_destroy functions on the top-...
0
votes
2answers
967 views

How are new[] and malloc implemented in Windows? [closed]

So when you call malloc or new [] from your C/C++ application, how does the CRT translate it into Windows API calls?
3
votes
1answer
3k views

At a higher level description, how is DLMALLOC supposed work?

There doesn't seem to be that many good descriptions that go into the specifics about how dlmalloc works. The sources I have come across so far mention dlmalloc, but then only goes on to explain what ...
3
votes
1answer
220 views

Heaps: Why is there a tradeoff between amount of space occupied (fragmentation), and speed at which operations are carried out?

Apparently, the two major judging criteria of the effectiveness of heaps are (1) how much we can minimize the amount of space it takes up and (2) how fast operations on the heap can be carried out, eg,...