about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-17 21:32:32 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-17 21:32:32 -0800
commit3921337b3fa1b6413206829c1a3e2e8836c153a9 (patch)
tree409fc826b027d0c7f158e042c1646901bb6280e8 /src
parenta617b3e5ac9e47d7a374a02ab091f050dc0bd556 (diff)
downloadteliva-3921337b3fa1b6413206829c1a3e2e8836c153a9.tar.gz
yet another stab at reorganizing stack assertions
Diffstat (limited to 'src')
-rw-r--r--src/lua.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lua.c b/src/lua.c
index 02f660b..a0c763f 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -424,20 +424,13 @@ static void update_definition (lua_State *L, const char *name, char *new_content
 
 extern void save_tlv (lua_State *L, char *filename);
 int load_editor_buffer_to_current_definition_in_image(lua_State *L) {
-  int oldtop = lua_gettop(L);
   char new_contents[8192] = {0};
   read_editor_buffer(new_contents, 8190);
   update_definition(L, Current_definition, new_contents);
   save_tlv(L, Image_name);
   /* reload binding */
-  int status = luaL_loadbuffer(L, new_contents, strlen(new_contents), Current_definition);
-  if (status == 0) status = docall(L, 0, 1);
-  if (lua_gettop(L) != oldtop) {
-    endwin();
-    printf("load_editor_buffer_to_current_definition_in_image: memory leak %d -> %d\n", oldtop, lua_gettop(L));
-    exit(1);
-  }
-  return status;
+  return luaL_loadbuffer(L, new_contents, strlen(new_contents), Current_definition)
+      || docall(L, 0, 1);
 }
 
 
@@ -448,6 +441,7 @@ extern int resumeEdit (lua_State *L);
 int edit_current_definition (lua_State *L) {
   int back_to_big_picture = edit(L, "teliva_editor_buffer");
   // error handling
+  int oldtop = lua_gettop(L);
   while (1) {
     int status;
     status = load_editor_buffer_to_current_definition_in_image(L);
@@ -458,6 +452,11 @@ int edit_current_definition (lua_State *L) {
     back_to_big_picture = resumeEdit(L);
     lua_pop(L, 1);
   }
+  if (lua_gettop(L) != oldtop) {
+    endwin();
+    printf("edit_current_definition: memory leak %d -> %d\n", oldtop, lua_gettop(L));
+    exit(1);
+  }
   return back_to_big_picture;
 }
 
@@ -947,6 +946,7 @@ int restore_editor_view (lua_State *L) {
   lua_settop(L, editor_state_index);
   int back_to_big_picture = edit_from(L, "teliva_editor_buffer", rowoff, coloff, cy, cx);
   // error handling
+  int oldtop = lua_gettop(L);
   while (1) {
     int status;
     status = load_editor_buffer_to_current_definition_in_image(L);
@@ -957,6 +957,11 @@ int restore_editor_view (lua_State *L) {
     back_to_big_picture = resumeEdit(L);
     lua_pop(L, 1);
   }
+  if (lua_gettop(L) != oldtop) {
+    endwin();
+    printf("edit_from: memory leak %d -> %d\n", oldtop, lua_gettop(L));
+    exit(1);
+  }
   return back_to_big_picture;
 }
 
4-06 11:33:29 -0700 1023' href='/akkartik/mu/commit/cpp/011load?h=hlt&id=cc3b58b6370f27fb3fb600d6538a542c2fe44d36'>cc3b58b6 ^
363be37f ^
a5840f21 ^
363be37f ^
08cf048f ^
a316f1e4 ^
08cf048f ^
fe263c52 ^

1ead3562 ^
1625e908 ^

14274372 ^
1ead3562 ^
a0b9fa55 ^
1625e908 ^

a0b9fa55 ^
ad8e984f ^
fe263c52 ^
ad8e984f ^
1b76245c ^
ad8e984f ^
fe263c52 ^
781f2462 ^

36594a43 ^
1625e908 ^

b24eb476 ^
df40cb6e ^

712b442f ^
3c93ddcb ^
50e0065e ^
df40cb6e ^
1b76245c ^
df40cb6e ^
c4e143d6 ^
795f5244 ^
795f5244 ^
b2ec0969 ^
a0b9fa55 ^
1b76245c ^
795f5244 ^
14274372 ^
70f70118 ^
50e0065e ^
8f0a9149 ^
795f5244 ^
14274372 ^

70f70118 ^
f5dfb7f7 ^
3c93ddcb ^
66b97b4d ^
9dcbec39 ^
3c93ddcb ^
36594a43 ^

8d72e565 ^
70f70118 ^
9f95c745 ^
8d72e565 ^
36594a43 ^




0a2026a6 ^
08cf048f ^
1b76245c ^
0a2026a6 ^

36594a43 ^

08cf048f ^
1f7e3c05 ^
08cf048f ^
1b76245c ^
0a2026a6 ^

0a2026a6 ^
36594a43 ^
1f7e3c05 ^
36594a43 ^
0a2026a6 ^
c4e143d6 ^
781f2462 ^
781f2462 ^
ac0e9db5 ^
36594a43 ^
05d17773 ^
b2ec0969 ^
08cf048f ^
1b76245c ^
0a2026a6 ^


36594a43 ^



c4e143d6 ^
36594a43 ^
36594a43 ^


35064671 ^
1b76245c ^
35064671 ^

e6692482 ^

36594a43 ^
c4e143d6 ^
36594a43 ^
36594a43 ^
b2ec0969 ^
5683823a ^
c4e143d6 ^
9f95c745 ^
c4e143d6 ^
9f95c745 ^
08cf048f ^
1b76245c ^
0a2026a6 ^


36594a43 ^


3c93ddcb ^
8619c618 ^

36594a43 ^
1f7e3c05 ^
36594a43 ^


536a22c1 ^

1f7e3c05 ^
536a22c1 ^
36594a43 ^

08cf048f ^
36594a43 ^




536a22c1 ^
36594a43 ^






a316f1e4 ^

08cf048f ^
a316f1e4 ^
1f7e3c05 ^
a316f1e4 ^

7232de70 ^
36594a43 ^

3c93ddcb ^











100157d1 ^
08cf048f ^
100157d1 ^
08cf048f ^
100157d1 ^


7e423e26 ^

5ed9bb13 ^
7e423e26 ^
a0b9fa55 ^
7e423e26 ^
a0b9fa55 ^
c5e965d8 ^
a0b9fa55 ^

c5e965d8 ^
7e423e26 ^

a316f1e4 ^
a316f1e4 ^

a316f1e4 ^

c4e143d6 ^
a316f1e4 ^
a316f1e4 ^



100157d1 ^
518e6c5e ^
1ead3562 ^

518e6c5e ^
1ead3562 ^
bc643692 ^
100157d1 ^
35457609 ^
acc4792d ^

100157d1 ^

1ead3562 ^
100157d1 ^
bc643692 ^
100157d1 ^
35457609 ^
acc4792d ^

100157d1 ^
051c4738 ^
1ead3562 ^
100157d1 ^
bc643692 ^
100157d1 ^

35457609 ^
acc4792d ^

100157d1 ^
051c4738 ^
1ead3562 ^
bc643692 ^
100157d1 ^
bc643692 ^
100157d1 ^
35457609 ^
acc4792d ^

35457609 ^
acc4792d ^

100157d1 ^

1ead3562 ^
bc643692 ^
100157d1 ^
35457609 ^
acc4792d ^

100157d1 ^
96ac511e ^
1ead3562 ^
3a787ca7 ^
96ac511e ^
3a787ca7 ^
96ac511e ^
72c4fb2d ^
1ead3562 ^
72c4fb2d ^



a4ef18b1 ^
1ead3562 ^
bc643692 ^
a4ef18b1 ^
35457609 ^
acc4792d ^

a4ef18b1 ^
96ac511e ^
1ead3562 ^
bc643692 ^
96ac511e ^
35457609 ^
acc4792d ^


96ac511e ^

1ead3562 ^
bc643692 ^
96ac511e ^
35457609 ^
acc4792d ^



f02842a9 ^

1ead3562 ^
bc643692 ^
f02842a9 ^
35457609 ^
acc4792d ^



0060093e ^

1ead3562 ^
8a3d101e ^
0060093e ^
acc4792d ^
076f39b8 ^



076f39b8 ^





14274372 ^
a0b9fa55 ^
5ed9bb13 ^
1ead3562 ^
14274372 ^

1ead3562 ^
14274372 ^

5ed9bb13 ^
14274372 ^
a0b9fa55 ^
1ead3562 ^
14274372 ^

1ead3562 ^
14274372 ^

5ed9bb13 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366