Skip to main content
Best practices
1 vote
12 replies
128 views

I've been researching this for a day and I've found a lot of conflicting information on multiple websites. I'm writing a simple test that will allocate and initialize a char** (array of strings, char*...
Maryann's user avatar
  • 39
1 vote
0 answers
57 views

I mean that i is incremented by 1 right, then how does ptr + i equals ith block of memory since int size is 4? int i, n; printf("Enter the number of Integers: "); scanf("%d&...
0x0pralad0x0's user avatar
0 votes
1 answer
77 views

I simulated a scenario in Java that leads to severe glibc memory fragmentation. Step one: simulate a multithreaded environment with 600 threads. Step two: every second, start two new threads that ...
Forever's user avatar
  • 41
Best practices
1 vote
7 replies
171 views

So I'm making a linked list for one of my school assignments in C. I found this website that has some helpful code snippets, and I noticed that they use malloc() to allocate more memory every time ...
Klumpy7's user avatar
  • 123
2 votes
2 answers
152 views

I'm refreshing my C skills (been decades) and ran across something I don't quite understand. I'm working on some code that involves a lot of bit shifting, masking, etc. I have one function that ...
Maryann's user avatar
  • 39
2 votes
2 answers
88 views

I am trying to catch memory-related bugs such as use-after-free by mallopt(M_PERTURB, <value>). According to the doc, the memory will be initialized to value when it has been released by free. ...
davidhcefx's user avatar
-4 votes
0 answers
102 views

While implementing a Dijkstra-Search on a Graph, I call a seperate method to perform the search, handing it a pointer to my nodes and direct values for start/endpoint and array size. Notably,t he ...
Tom Tom's user avatar
-6 votes
2 answers
274 views

I want to try catch the free(hello); so that the free(world); can still be executed for freeing all allocated memory in the main program. int main() { const char *hello = "Hello World"; ...
stackbiz's user avatar
  • 1,914
4 votes
2 answers
224 views

I don't know how to reset the value field inside the Hello struct. It's a pointer pointed to an outside passed input argument. typedef struct Hello { void *value; } Hello; Hello* create_hello() { ...
stackbiz's user avatar
  • 1,914
1 vote
0 answers
80 views

We use the mspace feature of Doug Lea's Malloc often referred to as dlmalloc. We have an mspace with 250 MB of objects and free all the objects. After calling mspace_trim() the size is 150 MB. We were ...
brian beuning's user avatar
0 votes
3 answers
266 views

When the array type is a "void *", then it can be allocated by: void **void_array; void_array = malloc(sizeof(void*) * 1); But, if the array type is a struct Hello *, then what should be ...
stackbiz's user avatar
  • 1,914
9 votes
4 answers
1k views

I used malloc to define an index because each line had a different number of elements (simplified example below): int** Index=malloc(2*sizeof(int*)); Index[0]=malloc(2*sizeof(int)); Index[1]=malloc(3*...
Anonymus Anonyma's user avatar
4 votes
5 answers
260 views

I have the following code snippet in C that declares multiple one-dimensional and two-dimensional arrays of type double. double func(double alphas[], double betas[], double rhos[], double **X, ...
sonny's user avatar
  • 49
3 votes
2 answers
128 views

I have written some programs with OMP reduction directive in Fortran and in C. But the data types were simple (int, float, arrays with fixed size, ...) and reduction-identifiers used were implicitly ...
Stef1611's user avatar
  • 2,515
-2 votes
2 answers
136 views

This was a question in a C Programming assignment given to me as a part of last week's assessment. Requesting everyone to kindly explain what needs to be done and how it needs to be done. Kindly note ...
Gargi Chaturvedi's user avatar

15 30 50 per page
1
2 3 4 5
625