static SLang_Array_Type *string_list_to_array (_pSLString_List_Type *p, int delete_list) { unsigned int num; SLindex_Type inum; SLang_Array_Type *at; char **buf; buf = p->buf; num = p->num; if (delete_list == 0) return _pSLstrings_to_array (buf, num); inum = (SLindex_Type) num; if (num == 0) num++; /* so realloc succeeds */ /* Since the list is to be deleted, we can steal the buffer */ if ((num != p->max_num) && (NULL == (buf = (char **)SLrealloc ((char *) buf, sizeof (char *) * num)))) { _pSLstring_list_delete (p); return NULL; } p->max_num = num; p->buf = buf; if (NULL == (at = SLang_create_array (SLANG_STRING_TYPE, 0, (VOID_STAR) buf, &inum, 1))) { _pSLstring_list_delete (p); return NULL; } p->buf = NULL; _pSLstring_list_delete (p); return at; }
int SLang_set_argc_argv (int argc, char **argv) { SLang_Array_Type *at = _pSLstrings_to_array (argv, argc); if (at == NULL) return -1; if (-1 == add_argc_argv (at)) { SLang_free_array (at); return -1; } return 0; }
static void get_frame_info (int *depth) { #define NUM_INFO_FIELDS 5 static SLFUTURE_CONST char *field_names[NUM_INFO_FIELDS] = { "file", "line", "function", "locals", "namespace" }; SLtype field_types[NUM_INFO_FIELDS]; VOID_STAR field_values[NUM_INFO_FIELDS]; SLang_Array_Type *at = NULL; _pSLang_Frame_Info_Type f; unsigned int i; if (-1 == _pSLang_get_frame_fun_info ((unsigned int)*depth, &f)) return; i = 0; field_values[i] = (VOID_STAR) &f.file; if (f.file == NULL) field_types[i] = SLANG_NULL_TYPE; else field_types[i] = SLANG_STRING_TYPE; i++; field_values[i] = &f.line; field_types[i] = SLANG_UINT_TYPE; i++; field_values[i] = (VOID_STAR) &f.function; if (f.function == NULL) field_types[i] = SLANG_NULL_TYPE; else field_types[i] = SLANG_STRING_TYPE; i++; if (f.locals == NULL) { field_types[i] = SLANG_NULL_TYPE; field_values[i] = (VOID_STAR) &f.locals; } else { if (NULL == (at = _pSLstrings_to_array (f.locals, f.nlocals))) return; field_values[i] = &at; field_types[i] = SLANG_ARRAY_TYPE; } i++; field_values[i] = (VOID_STAR) &f.ns; if (f.ns == NULL) field_types[i] = SLANG_NULL_TYPE; else field_types[i] = SLANG_STRING_TYPE; i++; (void) SLstruct_create_struct (NUM_INFO_FIELDS, field_names, field_types, field_values); if (at != NULL) SLang_free_array (at); }