fixing SEXP_USE_GLOBAL_TYPES (may remove this soon though)

This commit is contained in:
Alex Shinn 2011-05-25 09:24:32 +09:00
parent a66dd88158
commit 47add027d6
3 changed files with 7 additions and 5 deletions

View file

@ -293,7 +293,7 @@
#endif
#ifndef SEXP_USE_WEAK_REFERENCES
#define SEXP_USE_WEAK_REFERENCES 1
#define SEXP_USE_WEAK_REFERENCES ! SEXP_USE_NO_FEATURES
#endif
#ifndef SEXP_USE_MALLOC

View file

@ -865,7 +865,7 @@ SEXP_API sexp_heap sexp_global_heap;
#endif
#if SEXP_USE_GLOBAL_TYPES
SEXP_API struct sexp_struct *sexp_type_specs;
SEXP_API struct sexp_type_struct *sexp_type_specs;
#define sexp_context_types(ctx) sexp_type_specs
#define sexp_type_by_index(ctx,i) (&(sexp_context_types(ctx)[i]))
#define sexp_context_num_types(ctx) sexp_num_types

8
sexp.c
View file

@ -161,9 +161,11 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
len = type_array_size*2;
if (len > SEXP_MAXIMUM_TYPES) len = SEXP_MAXIMUM_TYPES;
#if SEXP_USE_GLOBAL_TYPES
new = malloc(len * sizeof(_sexp_type_specs[0]));
for (i=0; i<num_types; i++)
memcpy(&(new[i]), &(sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
new = malloc(len * sizeof(sexp_struct));
for (i=0; i<num_types; i++) {
new[i].tag = SEXP_TYPE;
memcpy(&(new[i].value), &(sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
}
tmp = sexp_type_specs;
sexp_type_specs = new;
if (type_array_size > num_types) free(tmp);