We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e55c8c7 + e2413b1 commit d63adf7Copy full SHA for d63adf7
ChangeLog
@@ -1,3 +1,11 @@
1
+2023-06-18 (12.27)
2
+ COMMON: Fix redim regression
3
+ PLUGINS: Added mechanism for cleaning up resources when the associated map falls out of scope
4
+
5
+2023-05-12 (12.27)
6
+ CONSOLE: Fix image save
7
+ ANDROID: Fix download error when there are duplicate scratch.bas files
8
9
2023-03-26 (12.26)
10
ANDROID: Fix setenv error #187
11
ANDROID: update web UI dependencies
configure.ac
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl
-AC_INIT([smallbasic], [12.26])
+AC_INIT([smallbasic], [12.27])
AC_CONFIG_SRCDIR([configure.ac])
12
13
AC_CANONICAL_TARGET
samples/distro-examples/tests/array.bas
@@ -426,4 +426,15 @@ p(asc("|")) = 1
426
p(asc("}")) = 1
427
p(asc("~")) = 1
428
429
+'
430
+' https://www.syntaxbomb.com/smallbasic/redim-why-to-keep-old-versons/
431
432
+a = [0,1,2,3,4,5,6,7,8,9,10,11]
433
+redim a(11) : if a != [0,1,2,3,4,5,6,7,8,9,10,11] then throw str(a)
434
+redim a(1, 11) : if a != [0,1,2,3,4,5,6,7,8,9,10,11;0,0,0,0,0,0,0,0,0,0,0,0] then throw str(a)
435
+redim a(2, 10) : if a != [0,1,2,3,4,5,6,7,8,9,10;11,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0] then throw str(a)
436
437
+redim a(10) : if a != [0,1,2,3,4,5,6,7,8,9,10] then throw str(a)
438
+redim a(0 to 7): if a != [0,1,2,3,4,5,6,7] then throw str(a)
439
+redim a(0 to 1): if a != [0,1] then throw str(a)
440
src/common/blib.c
@@ -210,8 +210,6 @@ void cmd_dim(int preserve) {
210
}
211
if (!preserve || var_p->type != V_ARRAY) {
212
v_new_array(var_p, size);
213
- } else if (v_maxdim(var_p) != dimensions) {
214
- err_matdim();
215
} else {
216
// preserve previous array contents
217
v_resize_array(var_p, size);
src/common/hashmap.c
@@ -126,6 +126,8 @@ void hashmap_create(var_p_t map, int size) {
126
map->type = V_MAP;
127
map->v.m.count = 0;
128
map->v.m.id = -1;
129
+ map->v.m.lib_id = -1;
130
+ map->v.m.cls_id = -1;
131
if (size == 0) {
132
map->v.m.size = MAP_SIZE;
133
src/common/plugins.c
@@ -39,6 +39,7 @@ typedef int (*sblib_exec_fn)(int, int, slib_par_t *, var_t *);
39
typedef int (*sblib_getname_fn) (int, char *);
40
typedef int (*sblib_count_fn) (void);
41
typedef int (*sblib_init_fn) (const char *);
42
+typedef int (*sblib_free_fn) (int, int);
43
typedef void (*sblib_close_fn) (void);
44
45
typedef struct {
@@ -47,6 +48,7 @@ typedef struct {
47
48
void *_handle;
49
sblib_exec_fn _sblib_proc_exec;
50
sblib_exec_fn _sblib_func_exec;
51
+ sblib_free_fn _sblib_free;
52
ext_func_node_t *_func_list;
53
ext_proc_node_t *_proc_list;
54
uint32_t _id;
@@ -304,6 +306,7 @@ static void slib_import_routines(slib_t *lib, int comp) {
304
306
305
307
lib->_sblib_func_exec = slib_getoptptr(lib, "sblib_func_exec");
308
lib->_sblib_proc_exec = slib_getoptptr(lib, "sblib_proc_exec");
309
+ lib->_sblib_free = slib_getoptptr(lib, "sblib_free");
310
sblib_count_fn fcount = slib_getoptptr(lib, "sblib_proc_count");
311
sblib_getname_fn fgetname = slib_getoptptr(lib, "sblib_proc_getname");
312
@@ -471,6 +474,10 @@ static int slib_exec(slib_t *lib, var_t *ret, int index, int proc) {
471
474
free(ptable);
472
475
473
476
477
+ if (success && v_is_type(ret, V_MAP)) {
478
+ map_set_lib_id(ret, lib->_id);
479
+ }
480
481
return success;
482
483
@@ -598,6 +605,13 @@ int plugin_funcexec(int lib_id, int index, var_t *ret) {
598
605
return result;
599
606
600
607
608
+void plugin_free(int lib_id, int cls_id, int id) {
609
+ slib_t *lib = get_lib(lib_id);
610
+ if (lib && lib->_sblib_free) {
611
+ lib->_sblib_free(cls_id, id);
612
613
+}
614
601
615
void plugin_close() {
602
616
for (int i = 0; i < MAX_SLIBS; i++) {
603
617
if (plugins[i]) {
@@ -626,5 +640,6 @@ int plugin_get_kid(int lib_id, const char *keyword) { return -1; }
626
640
void *plugin_get_func(const char *name) { return 0; }
627
641
int plugin_procexec(int lib_id, int index) { return -1; }
628
642
int plugin_funcexec(int lib_id, int index, var_t *ret) { return -1; }
643
+void plugin_free(int lib_id, int cls_id, int id) {}
629
644
void plugin_close() {}
630
645
#endif
src/common/plugins.h
@@ -55,6 +55,11 @@ int plugin_procexec(int lib_id, int index);
55
//
56
int plugin_funcexec(int lib_id, int index, var_t *ret);
57
58
+//
59
+// cleanup any resources held against the map data
60
61
+void plugin_free(int lib_id, int cls_id, int id);
62
63
64
// closes the plugin system
65
src/common/var.c
@@ -555,6 +555,7 @@ void v_move(var_t *dest, const var_t *src) {
555
break;
556
case V_ARRAY:
557
memcpy(&dest->v.a, &src->v.a, sizeof(src->v.a));
558
+ v_maxdim(dest) = v_maxdim(src);
559
560
case V_PTR:
561
dest->v.ap.p = src->v.ap.p;
@@ -565,6 +566,8 @@ void v_move(var_t *dest, const var_t *src) {
565
566
dest->v.m.count = src->v.m.count;
567
dest->v.m.size = src->v.m.size;
568
dest->v.m.id = src->v.m.id;
569
+ dest->v.m.lib_id = src->v.m.lib_id;
570
+ dest->v.m.cls_id = src->v.m.cls_id;
571
572
case V_REF:
573
dest->v.ref = src->v.ref;
0 commit comments