sim-c
sim-c copied to clipboard
[FEATURE] Dynamic memory allocation
Is your feature request related to a problem? Please describe. Dynamic memory allocation in simC.
Describe the solution you'd like Open ended, come up with an intuitive syntax.
Note: Discuss syntax with a maintainer before implementing.
@frankhart2018 Hi I want to work upon this issue. will use malloc for this purpose..
@Gaurav7888 please mention the syntax here, once that is approved I or any other maintainer can assign you to this.
Like (pointer type ) malloc(sizeof() ) This is in general syntax gonna use .
DMA includes allocating, reallocating, and deleting.
@Aayush-99 @PranshulDobriyal
free() could be used for deletion I just checked out there is something called realloc() for this purpose , i will learn how to use it and apply to solve this issue. @frankhart2018
@Gaurav7888 What syntax do you propose for the same in SimC ?
@PranshulDobriyal cpython have some functions to do abv things .
@Gaurav7888 Yes that will explain the backend of the desired functions, but what front-end (syntax in simC) do you propose. For ex- front-end (SimC code) -> print("hello world!!") back-end - various functions that generate the corresponding C code -> printf("hello world!!");
@Gaurav7888 They are asking for something like:
Example of Sim-C allocating memory:
SimC code:
var i = new int
var j = new int[10]
Generated C code:
int* i = malloc(sizeof(int));
int* j = malloc(10*sizeof(int));
It's like SimC will interpreter the command.
@frankhart2018 Sim-C should predict the type of the variable? If so, it's change a lot of expected code.
A example.
SimC code:
var i = new var
var j = new var[10]
What do we need dynamic memory allocation for other than variable length arrays?
Can you start a discussion for this @victorjzsun.
Created a discussion here