Free a Unicode struct [closed] - c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a pointer to an wide char array, which I want to free.
What is the easiest way to do this?

That depends on how the memory was allocated.
If malloc() was used, pass the address of the allocated memory to free(). If it came from a third-party library, see that library's documentation. If the struct is actually a local or global variable, don't worry about cleaning it up at all.

Related

Why cant you resize array in C using malloc? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I know that malloc allows you to resize anything you want by allocating space for it. But why does this not work for resizing arrays in C?
malloc is used to allocate memory not resizing. If you want resizing check realloc.

What does "memory allocation" actually mean in C [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I was in an interview recently where I was given a piece of paper with a few function signatures and asked to fill in the code, I was also instructed not to "allocate memory".
The question was relatively simple (Smallest value in a list) so I solved it recursively which the interviewers seemed unimpressed by, they seemed to suggest that I could have declared variables on the stack but i was nervous and regrettably didn't press the interviewer on it.
What does it mean to "allocate" memory in C?
Allocate memory means you keep for your program an amount of memory situated in the HEAP section. On the contrary, when you don't allocate memory, new variables are stored in the STACK section.
See What and where are the stack and heap?

Are there differences between pointers to object stored on stack and heap? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Are there differences between pointers to object stored on stack and heap ? Are there internal representation in common C/C++ compilers (or JVM/LLVM) differs ?
this is very interesting question somehow related to main : memory location patterns on stack and heap
A pointer is a pointer. No matter where it points to.
I mean: you can assign to the same pointer both the address of a region on the stack and on the heap, don't you? So there cannot be any intrinsic difference between a pointer pointing here or there.
The difference being ones on the stack you do not need to free

What standard library function in C copys a zero byte to the stack? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Which function in the C library copies the zero bytes(\x00) into the stack, leading to a buffer overflow?
There is no such standard function. C doesn't even specify that there should be a stack.
If you happen to be on a stack machine, and are willing to make assumptions about the stack's layout, you can certainly use memset() to write 0-bytes into stack memory.
strcpy and sprintf copies a zero byte to the end of the buffer they use. This is why it is recommended to use strncpy and snprintf

How to allocate 8kb memory for a character array and get the starting and ending address of it? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i need to allocate 8 kb to an array and need to get the starting and ending address of the array. then i need to check those virtual memory address are aligned contiguously or not in the actual physical memory. how to do that. please help. thanks in advance.
Use MmAllocateContiguousMemory function. It allocates a range of physically contiguous memory.

Resources