Questions tagged [allocation]

Memory allocation is an operation of giving a program a block of memory.

1869 questions
0
votes
2 answers

visualize latent dirichlet allocation results

I'm trying to use Latent Dirichlet Allocation LDA from genism library for Python. Is there any way to display results of the algorithm over training set in a form of a graph? Maybe with Venn's diagrams, or some chars?
striki
  • 1
0
votes
2 answers

uninitialized value was created by a heap allocation. why?

After running Valgrind on my code I got an error: uninitialized value was created by a heap allocation. My code: void adicionaHashtag(char* x){ char*y=malloc(sizeof(x));/***ERROR IS HERE***/ int i; for(i=0; i
0
votes
1 answer

Trying to do dynamic memory allocation in words (text) from file in c

im trying to find out the number of different words of a text in a file, using dynamic memory allocation. however, i dont get the right results. the text can contain punctuation. the program is below: #include #include #include…
0
votes
3 answers

Double pointer array in c++

I was reading a program about BTree, there I came across this : BTreeNode **C. I understand that it is a 2d array but it was initialized as C=new BTreeNode *[2*t];. I can't understand this: is this a 2d array with dynamic rows and 2t columns…
Nikhil Verma
  • 1,777
  • 1
  • 20
  • 41
0
votes
1 answer

Declaration and memory allocation to target parameter in copy_from_user call

I have a pointer to a data buffer in user space mode, and now I want to copy the value of that data to kernel mode with "copy_from_user" function. Assume that my data pointer is "data.ptr.buffer" and it's size is "data_size". the declaration of…
Cert
  • 99
  • 1
  • 2
  • 9
0
votes
2 answers

c++ deallocator lost after cast?

I have a custom allocator for a vector, but I would rather not have it in the code everywhere. So I thought to cast it to a normal vector vector * createVector(size_t nfft) { vector > * data = new…
Matthias Pospiech
  • 3,130
  • 18
  • 55
  • 76
0
votes
1 answer

Dynamic memory allocation in C: why do I get an error?

Below there is a unfinished code for my program, at the current stage, however, I am getting errors (Xcode log: Subscripted value is not array, pointer or vector). I suppose that it has to do with memory allocation. This error occurs in the if…
0
votes
1 answer

Is Python's heap allocator slowing my code drastically as overall memory usage increases?

I have a program that needs to continually - at set intervals, within certain time constraints - pop/update a dict of lists of lists of varying objects. def update_dwindow_tables(cpos): # remove old tables kill_ids = [(f,l) for f,l in…
Jon O.
  • 13
  • 1
  • 5
0
votes
3 answers

Infinite loop in custom malloc()

I'm trying to implement my own malloc() function in C, but I'm facing this problem. The first two allocated addresses are correct, but after that, it doesn't show the others addresses. I mean, it gets stuck in an infinite loop. However, if I remove…
Newton05
  • 1
  • 1
0
votes
2 answers

Adding memory allocation to a C++ array

Question What is the most efficient way to add memory allocation to an already declared variable? For example: int n=3; int m = 4; int * p; p = new int[n]; for(int i = 0;i
JoGooD
  • 3
  • 2
0
votes
1 answer

Accessing Dynamically created object c++

I have dynamically created an Sensor object with new. However, when I try to use the object, it looks like the Sensor's members are uninitialized. I have verified that the creation and initialization of the object is successful. I don't believe this…
user3014816
  • 63
  • 2
  • 5
0
votes
1 answer

Using only a fraction of a very large pre-allocated array

When we allocate an array in Fortran or C, my understanding is that the memory is first allocated in the so-called virtual memory, while the physical memory is allocated only when we write data onto (some part of) the array (e.g., based on this…
roygvib
  • 7,218
  • 2
  • 19
  • 36
0
votes
1 answer

Read array of unknown size from keyboard

I want to insert an unknown number of values in an array (no matter the order). I could first read how many values are to be inserted, then allocate the allocatable array, and finally read its values, as in the following code PROGRAM try IMPLICIT…
Enlico
  • 23,259
  • 6
  • 48
  • 102
0
votes
1 answer

Multidimensional array segfault and 139 (0x8B) return

I'm trying to allocate a multidimensional array to read information from a file and then printing it to check if it is working properly and to get the array information to a 2D array afterwards (not done yet). But for some reason it gives me…
0
votes
0 answers

Array double datatype

Can someone tell me why this code doesn't work? The user inputs a number, let's say 10, and it's saved into an int num. I want to make a double datatype array which can store 10 or num amount of doubles. Why do I keep getting an error when I write…