Questions tagged [allocation]

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

1869 questions
0
votes
2 answers

How to Dynamically Allocate a string within a struct with fscanf or fgets?

I'm trying to allocate a string within a struct with fscanf, I tried this: #include #include #include #include #include typedef struct _SPerson { char *name; char *surname; char *id; …
user3289840
  • 241
  • 1
  • 2
  • 10
0
votes
0 answers

Allocating Physically Contiguous Pages from User Space in Linux

I need to allocate physically contiguous pages from user space and get back the physical address. How can I do so? I need it physically contiguous because I'm working in-conjunction with hardware that needs that. get_free_pages as I understood is…
Hanna Khalil
  • 975
  • 1
  • 10
  • 28
0
votes
1 answer

Allocation fault (function or code) and strange behavior in C

I stumbled upon this problem while trying to make a programm that solves linear systems of equasions using Gaussian elimination. I am sorry for this long part of the code but i really need help and i think that this way you can see if i made some…
refa
  • 11
  • 1
  • 5
0
votes
2 answers

Does appending/removing entries to a Java list reallocate memory?

This is low-level memory question about how Java performs .add and .remove on an ArrayList or other types of lists. I would think that Java would have to do a reallocation of memory to append/remove items to a list, but it could be doing something…
mjswartz
  • 715
  • 1
  • 6
  • 19
0
votes
2 answers

Trying to free allocated memory borrowed when initializing an object, but getting Xcode warning

OK, so I have my main.m program code, and mvds suggested I free the allocated memory I borrowed from my class when I created a new instance. For some reason, when I attempt to free the memory using [converter free]; It gives me a warning saying…
Qcom
  • 18,263
  • 29
  • 87
  • 113
0
votes
0 answers

Getline() and cin manipulate dynamic array

I'm totally lost and confused and could use some help. I'm currently working on a small command line-based game. For this I wrote a class Inventory, dynamically creating an array of invSpace-objects, each space representing a pair of a pointer to an…
Benniczek
  • 1
  • 2
0
votes
1 answer

dynamic array is allocated without malloc

How did the array get created, even if malloc is not used? #include #include int main() { int n,i,*ptr,sum=0; printf("Enter number of elements: "); scanf("%d",&n); printf("Enter elements of array: "); …
0
votes
1 answer

Arbitrary-strings using getline

So basically what my program did before i had to change it so that it would accept arbitrary values, was to take x-amount of words and the size of the words would also be arbitrary. (both are user inputted). I did this via a multiArray. Then sorted…
Joel
  • 5,732
  • 4
  • 37
  • 65
0
votes
1 answer

How to pre-allocate and assign a value to a variable whose name is written in a cell array?

% Data Fields = {'History','Maths','English','French','Geography','Philosophy'}'; Students=…
0
votes
2 answers

Declare global contiguous 2d array at runtime. The dimensions are unknown at compile time C

I want to declare a global 2d array in C, and allocate contiguous memory at runtime because the minor dimension is unknown at compile time. I would like to dereference the array with 2-indices notation A[i][j]. If the array wasn't global c99…
NickSar68
  • 55
  • 5
0
votes
1 answer

How does c++ stl map manage memory, and how to get around it

I am using an stl map, linking an int key to objects of a class I defined, Account. The program involves alot of multithreading. Some of the threads send account objects by reference to functions that make changes in these objects. My question is…
Avivos
  • 11
  • 2
0
votes
1 answer

What happens to memory behind the scenes when creating new objects inside of C# for loops?

I'm trying to understand when memory gets allocated and when the garbage collector collects garbage. Let's say that I have some code like this: foreach (FileInfo f in File){ foreach (DataAtrribute d in f){ string name = d.name; …
0
votes
2 answers

Allocated bytes in Java applications

Is there a way of finding how many bytes were allocated in a Java application? If possible, without changing the code? Thanks.
franco
  • 297
  • 4
  • 9
0
votes
2 answers

Specifying Resource Allocation algorithm?

Can someone help me to solve or specify what type of problem is this: I have a set of resources and a number of users, and for each user there is a specific subset of resources that can choose a single resource from for allocation. Two different…
0
votes
1 answer

An issue allocating data in c

I've got this homework, which is to make an implementation of the "tail" command in Linux and this is what i have so far: #include #include #include #include #include #include…