4,184 questions
0
votes
1
answer
62
views
Unfreeable Memory when Using Capstone
I disassembled a 7,838,304-Byte portion of /usr/lib/x86_64-linux-gnu/dri/i965_dri.so using Capstone as shown below:
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#...
1
vote
0
answers
57
views
How does i in 'scanf("%d", ptr + i);' counts to 4? [duplicate]
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&...
Best practices
1
vote
7
replies
170
views
Memory allocation when using a linked list
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 ...
2
votes
0
answers
88
views
How to properly allocate dynamic memory for matrix operations in C [duplicate]
I am trying to learn C, and I want to specifically work with arrays and matrices as I do scientific simulations (coming from python!!). After writing few basic 1-D array codes in C, I am going for ...
0
votes
0
answers
26
views
How to preallocate memory for a map in odin?
I'm learning odin, and I'm writing a program where the map allocating memory, growing and doing its checks is a considerable part of my program running time, is there a way to have a map where I can ...
3
votes
4
answers
150
views
What's wrong with this code, which gets content (chars) from file and stores it in char**?
I have a small project (ed-like text editor for myself. Just want to edit some config files using it) and I have some problems with it.
workspace_file->flc = malloc(sizeof(char *));
...
-2
votes
2
answers
136
views
Facing issues with Structs and malloc in an assignment question [closed]
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 ...
1
vote
1
answer
123
views
dynamically resizing array in queue implementation [closed]
I'm trying to write a queue that will store strings. Using GDB I can tell that I make a memory allocation error in the function resizeQueue.
Here's the exact message:
Program received signal SIGTRAP, ...
0
votes
0
answers
207
views
Jax unable to allocate memory despite memory being free?
I have been having issues allocating memory on the GPU with jax. I am running on a cluster that gives me access to a RTX6000 (24GiB vram) which jax is attempting to allocate to.
Output of jax....
1
vote
1
answer
74
views
Memory management issues for a linear regression program in C
I am planning to make a Linear Regression model using C. It takes a set of m points as input from stdin using scanf. The points are defined as a struct:
typedef struct{
double x;
double y;
} ...
0
votes
0
answers
16
views
How can I determine why clSVMAlloc failed?
Most OpenCL API calls return a status/error value, either directly or via an out-parameter (example: clCreateBuffer()). While that is not as informative as a long-form string description, it can tell ...
0
votes
0
answers
103
views
Use array slicing to avoid memory allocation [duplicate]
Consider the following excerpt from Prometheus source code:
func (ls Labels) String() string {
var bytea [1024]byte // On stack to avoid memory allocation while building the output.
b := bytes....
11
votes
2
answers
367
views
Issue with aggregate initialization with the new operator
The following two codes behave as expected:
char* test1 = new char[20]{"abc"};
cout << test1;
Outputs: abc
int size = 20;
char* test1 = new char[size]{'a','b','c'};
cout << ...
1
vote
1
answer
91
views
uninitialized memory when using realloc for an array of structs [closed]
I have a parent struct that has an array of child structs and the length of it, and within each child struct is an array of numbers and the length of it. all of the arrays are defined using pointers ...
-3
votes
1
answer
171
views
Memory is not being allocated [closed]
I am sorry if the question is stupid. The problem is that memory for my dynamic array inside a static structure is not being allocated. The reason might be my pc (it is a really old notebook with only ...