Questions tagged [static-allocation]

38 questions
1
vote
1 answer

embedded c++ : dynamic typing without dynamic allocation?

Here's my issue, simplified: I have a code in C/C++, C for services, C++ for handling. I have an interface in C that returns a structure RawData that contains information which is cyclically updated. enum AnimalType_t { …
Guillaume D
  • 2,202
  • 2
  • 10
  • 37
1
vote
1 answer

What does "statically allocated" exactly mean in libc? One per library instance? One per program instance?

In (g)libc, for example in time and date functions like localtime, the manual says: The return value points to a statically allocated string which might be overwritten by subsequent calls to any of the date and time functions. As far as…
user7076126
1
vote
1 answer

Estimating memory footprint and CPU usage for a C library

I have a static library written in C, with no dynamic memory allocation. Until now, the library has only been used in an application for regular i386 Linux, where CPU and memory was plentiful. I now need to try building a version of the library…
Frode
  • 5,600
  • 1
  • 25
  • 25
1
vote
1 answer

c++ memory allocated at compile time

I read that while dynamic memory is allocated on the heap during runtime, static memory is allocated on the stack during compile time since the compiler knows how much memory has to be allocated at compile time. Consider the following code: int…
Botond
  • 2,640
  • 6
  • 28
  • 44
1
vote
1 answer

Incrementing pointer to static allocated array

By how much is pointer incremented in these situations and why? void f(int a[]) { a++; printf("%d", *a); } void g(int a[][M]) { a++; printf("%d", *a[0]); } Lets say that in main I have a static allocated array with n elements and…
Stefan Golubović
  • 1,225
  • 1
  • 16
  • 21
1
vote
3 answers

can i apply delete on this pointer inside a member function?

As I understand if the member function has been called using pointer to an object which is allocated dynamically, the object would get delete. But if the member function has been called using the object, which is allocated statically, then what will…
Prashant Mishra
  • 167
  • 1
  • 9
1
vote
6 answers

Can I increase the size of a statically allocated array?

I know its possible to increase the size of a dynamically allocated array. But can I increase the size of a statically allocated array? If yes,how? EDIT: Though this question is intended for C language, consider other languages too.Is it possible in…
Ravindra S
  • 6,302
  • 12
  • 70
  • 108
0
votes
1 answer

Segmentation fault in DAG

How to Fix this Segmentation fault in, I have tried Some alternatives but still it's not working. strcpy(temp->label,'\0'); strcpy(temp->target,'\0');
0
votes
0 answers

Best statically allocated data structure for writing and extending contiguous blocks of data?

Here's what I want to do: I have an arbitrary number of values of a different kind: string, int, float, bool, etc. that I need to store somehow. Multiple elements are often written and read as a whole, forming "contiguous blocks" that can also be…
glades
  • 3,778
  • 1
  • 12
  • 34
0
votes
1 answer

Synchronizing Statically Allocated Struct Instances between CPU and GPU

I have a struct that contains an array, and I want to copy the contents from an instance of that struct in CPU memory to another instance in GPU memory. My question is similar to this one. There are two big difference between this question and the…
0
votes
2 answers

Releasing statically allocated nsarray

I have a static array in my class. When do i release it? or I don't have to worry about it? I was thinking about releasing it in dealloc method but not sure. Thanks
BukLau
  • 69
  • 3
0
votes
3 answers

How are allocated arrays declared in a loop?

I'm puzzled over this function. int i; for(i = 1; i<10; i++){ int arr[i]; printf("%d\n",sizeof(arr)); } return 0; How can the space grow in a bounded (by ESP) stack memory? Is there a sort of compilation trick? EDIT for…
0
votes
1 answer

several questions about this sml recursion function

When f(x-1) is called, is it calling f(x) = x+10 or f(x) = if ... Is this a tail recursion? How should I rewrite it using static / dynamic allocation? let fun f(x) = x + 10 in let fun f(x) = if x < 1 then 0 else f(x-1) in f(3) …
0
votes
3 answers

Is it possible to create class String without using heap in C++?

I would like to write me own class String which will have interface similar to std::string. String class shall not use dynamic memory allocation. I need to have a c-tor: String(char* ptrToFirstCharInTab, char* ptrToLastElementInTab); And there…
0
votes
0 answers

static allocation and stack allocation in compiler design

I am not clear about was static and stack allocation are? Is static allocation static and stack allocation dynamic? Then where does heap allocation belong? How is activation record related to this? I thought activation record is a conceptual thing…
afsara_ben
  • 542
  • 1
  • 11
  • 30