malloc Questions
3
Solved
The GLib docs recommend use of the GLib Slice Allocator over malloc:
"For newly written code it is recommended to use the new g_slice API instead of g_malloc() and friends, as long as objects ar...
2
Solved
I am working on a program that decrypts some line of text in a file. First, another source code I created asks for shift and some text. Source code encrypts the text and writes it into a file.
Th...
Cuticle asked 26/5, 2019 at 21:16
6
Solved
A student asked the question and I didn't know for sure.
Guesses include: "counted", "clearing", "chunked", "complete", ...
The standard library documentation doesn't say what it stands for and ...
Charente asked 8/8, 2015 at 0:33
6
Solved
I'm trying to write a simple shared library that would log malloc calls to stderr (a sort of 'mtrace' if you will).
However, this is not working.
Here's what I do:
/* mtrace.c */
#include <dlf...
Ninety asked 21/5, 2011 at 16:3
3
Solved
I've seen both terms used for wrappers to memory allocators, whats the difference between these? (if any)
Barcroft asked 9/8, 2017 at 1:55
1
Solved
I am working on a Django python project with a postgres db hosted with render.com.
The code works fine on server and my imac. I recently got a Macbook Pro M3 (running sonoma). I have replicated the...
Timorous asked 30/11, 2023 at 11:16
10
Solved
I was trying to figure out how much memory I can malloc to maximum extent on my machine
(1 Gb RAM 160 Gb HD Windows platform).
I read that the maximum memory malloc can allocate is limited to phys...
Prebend asked 9/5, 2010 at 16:31
4
I keep hearing that memory pools can signficantly improve performance when allocating memory.. so why aren't they used in some way by traditional malloc implementations?
I know part of it is that ...
Monumental asked 8/5, 2020 at 20:34
3
Solved
Reading Martin Sustrick's blog on challenges attendant with preventing "undefined behavior" in C++, vs C, in particular the problem attendant with malloc() failing due to memory exhaustion, I was r...
Adjoint asked 16/1, 2014 at 20:42
8
Solved
Which is preferable way to allocate memory for a function that is frequently allocating and freeing memory ? Assume this function is getting called around 500 to 1000 times a second on a 1GHz Proce...
8
Solved
Unlike new and delete expressions, std::malloc does not call the constructor when memory for an object is allocated. In that case, how must we create an object so that the constructor will also be ...
Hindustan asked 8/6, 2010 at 6:2
18
Solved
I just saw this code:
artist = (char *) malloc(0);
...and I was wondering why would one do this?
6
Solved
I want to be able to vary the size of my array so I create one this way:
int* array;
array = malloc(sizeof(int)*10);//10 integer elements
I can use this like an array as you normally would, howe...
3
So I am very new to C. I have done a lot of programming in Java and am finding it very difficult to learn C.
Currently I am assigned to read in a file from our terminal window, which will contain...
8
Solved
Let's say I have this struct
typedef struct person{
char firstName[100], surName[51]
} PERSON;
and I am allocating space by malloc and filling it with some values
PERSON *testPerson = (PERSON*...
5
Solved
I would like to alloc a buffer that I can execute on Win32 but I have an exception in visual studio cuz the malloc function returns a non executable memory zone. I read that there a NX flag to disa...
Tichon asked 2/12, 2016 at 16:12
3
Solved
Does the typical malloc (for x86-64 platform and Linux OS) naively lock a mutex at the beginning and release it when done, or does it lock a mutex in a more clever way at a finer level, so that loc...
6
Solved
quick question
Can you use the free() function without having to prior call a malloc ??
ei.
void someFunc( void )
{
char str[6] = {"Hello"};
//some processing here ....
free(str);
}
I ge...
1
Solved
I am developing a program that is supposed to take a string as a parameter and display the number of occurrences of each word in their order of appearance.
I have a problem when the string contains...
5
I have a big problem with my iOS App: it crashes sometimes without detailed debug error.
The stack trace is empty. These are the only two lines in the stack trace:
crash start in UIApplicationMai...
Fortnightly asked 7/11, 2013 at 16:2
10
Solved
I want to know if a pointer points to a piece of memory allocated with malloc/new. I realize that the answer for an arbitrary address is "No you can't" but I do think it is possible to override mal...
Caputto asked 17/6, 2010 at 19:48
3
Solved
I'm coming back to you about my function char **my_str_to_word_array(char *str). The purpose is to separate the string at each non-printable ASCII character and include the above in a new row of th...
2
Solved
When I am trying to execute my program Its getting error like this -
sendip: malloc.c:4631: _int_malloc: Assertion `(unsigned long)(size)
>= (unsigned long)(nb)' failed
Tried capturing erro...
Befog asked 13/10, 2011 at 19:54
7
I built two programs, one using malloc and other one using mmap. The execution time using mmap is much less than using malloc.
I know for example that when you're using mmap you avoid read/writes ...
2
On Linux, we have this (GNU C library) function named mallinfo() which gives you some numbers relating to memory allocation:
struct mallinfo {
int arena; /* Non-mmapped space allocated (bytes) */
...
Manado asked 30/11, 2016 at 0:19
1 Next >
© 2022 - 2025 — McMap. All rights reserved.