Skip to content

Commit 7050da8

Browse files
abinashmeher999isuruf
authored andcommitted
basic on stack wherever possible in ext/*.c
1 parent 7512030 commit 7050da8

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

ext/symengine/ruby_rational.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "ruby_rational.h"
22

33
VALUE crational_init(VALUE self, VALUE rat_value) {
4-
basic_struct *this, *num_basic, *den_basic;
5-
num_basic = basic_new_heap();
6-
den_basic = basic_new_heap();
4+
basic_struct *this;
5+
basic num_basic, den_basic;
6+
7+
basic_new_stack(num_basic);
8+
basic_new_stack(den_basic);
79

810
Data_Get_Struct(self, basic_struct, this);
911

@@ -15,7 +17,7 @@ VALUE crational_init(VALUE self, VALUE rat_value) {
1517
GET_SYMINTFROMVAL(den, den_basic);
1618

1719
rational_set(this, num_basic, den_basic);
18-
basic_free_heap(num_basic);
19-
basic_free_heap(den_basic);
20+
basic_free_stack(num_basic);
21+
basic_free_stack(den_basic);
2022
return self;
2123
}

ext/symengine/symengine_macros.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "symengine.h"
33

44
void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
5-
basic_struct *num_basic, *den_basic, *temp;
5+
basic_struct *temp;
66
VALUE new_operand2, num, den;
77

88
switch(TYPE(operand2)) {
@@ -15,16 +15,17 @@ void sympify(VALUE operand2, basic_struct *cbasic_operand2) {
1515
num = rb_funcall(operand2, rb_intern("numerator"), 0, NULL);
1616
den = rb_funcall(operand2, rb_intern("denominator"), 0, NULL);
1717

18-
num_basic = basic_new_heap();
19-
den_basic = basic_new_heap();
18+
basic num_basic, den_basic;
19+
basic_new_stack(num_basic);
20+
basic_new_stack(den_basic);
2021

2122
GET_SYMINTFROMVAL(num, num_basic);
2223
GET_SYMINTFROMVAL(den, den_basic);
2324

2425
rational_set(cbasic_operand2, num_basic, den_basic);
2526

26-
basic_free_heap(num_basic);
27-
basic_free_heap(den_basic);
27+
basic_free_stack(num_basic);
28+
basic_free_stack(den_basic);
2829
break;
2930

3031
case T_DATA:

0 commit comments

Comments
 (0)