Skip to content

Commit c158354

Browse files
committed
fixed ti_Alloc(String/Equ) when alloc returns NULL. Also added attribute nonnull
1 parent 4be6b9e commit c158354

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/fileioc/fileioc.asm

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,8 @@ ti_AllocEqu:
101101
ld iy, 0
102102
add iy, sp
103103
ld hl, (iy + 3)
104-
ld iy, (iy + 6)
105104
push hl
106-
inc hl
107-
inc hl
108-
call ti._indcall
109-
pop de
110-
ld (hl), e
111-
inc hl
112-
ld (hl), d
113-
dec hl
114-
ret
105+
jr util_alloc_string_equ
115106

116107
;-------------------------------------------------------------------------------
117108
ti_AllocCplxList:
@@ -124,7 +115,6 @@ ti_AllocCplxList:
124115
ld iy, 0
125116
add iy, sp
126117
ld hl, (iy + 3)
127-
ld iy, (iy + 6)
128118
push hl
129119
add hl, hl
130120
jr util_alloc_var
@@ -140,7 +130,6 @@ ti_AllocList:
140130
ld iy, 0
141131
add iy, sp
142132
ld hl, (iy + 3)
143-
ld iy, (iy + 6)
144133
push hl
145134
jr util_alloc_var
146135

@@ -153,15 +142,16 @@ ti_AllocMatrix:
153142
; sp + 9 : pointer to alloc routine
154143
; return:
155144
; hl -> allocated space
156-
ld iy, 0
145+
ld iy, 3
157146
add iy, sp
158-
ld h, (iy + 3)
159-
ld l, (iy + 6)
160-
ld iy, (iy + 9)
147+
ld h, (iy + 0)
148+
ld l, (iy + 3)
161149
push hl
162150
mlt hl
163151
util_alloc_var:
164152
call ti.HLTimes9
153+
util_alloc_string_equ:
154+
ld iy, (iy + 6)
165155
inc hl
166156
inc hl
167157
push hl

src/fileioc/fileioc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ extern "C" {
8787
#define ti_MallocEqu(len) ti_AllocEqu((len), malloc)
8888

8989
/* @cond */
90-
string_t *ti_AllocString(unsigned len, void *(*malloc_routine)(size_t));
91-
list_t *ti_AllocList(unsigned dim, void *(*malloc_routine)(size_t));
92-
matrix_t *ti_AllocMatrix(uint8_t rows, uint8_t cols, void *(*malloc_routine)(size_t));
93-
cplx_list_t *ti_AllocCplxList(unsigned dim, void *(*malloc_routine)(size_t));
94-
equ_t *ti_AllocEqu(unsigned len, void *(*malloc_routine)(size_t));
90+
string_t *ti_AllocString(unsigned len, void *(*malloc_routine)(size_t)) __attribute__((__nonnull__(2)));
91+
list_t *ti_AllocList(unsigned dim, void *(*malloc_routine)(size_t)) __attribute__((__nonnull__(2)));
92+
matrix_t *ti_AllocMatrix(uint8_t rows, uint8_t cols, void *(*malloc_routine)(size_t)) __attribute__((__nonnull__(3)));
93+
cplx_list_t *ti_AllocCplxList(unsigned dim, void *(*malloc_routine)(size_t)) __attribute__((__nonnull__(2)));
94+
equ_t *ti_AllocEqu(unsigned len, void *(*malloc_routine)(size_t)) __attribute__((__nonnull__(2)));
9595
/* @endcond */
9696

9797
/**

0 commit comments

Comments
 (0)