*mb_debug_get allows 'val' to be NULL

This commit is contained in:
Wang Renxin 2015-04-24 14:52:14 +08:00
parent b86b44f081
commit b00677973e

View File

@ -3953,16 +3953,21 @@ int mb_debug_get(struct mb_interpreter_t* s, const char* n, mb_value_t* val) {
int result = MB_FUNC_OK; int result = MB_FUNC_OK;
_ls_node_t* v = 0; _ls_node_t* v = 0;
_object_t* obj = 0; _object_t* obj = 0;
mb_value_t tmp;
mb_assert(s && n && val); mb_assert(s && n);
v = _ht_find(s->global_var_dict, (void*)n); v = _ht_find(s->global_var_dict, (void*)n);
if(v) { if(v) {
obj = (_object_t*)(v->data); obj = (_object_t*)(v->data);
mb_assert(obj->type == _DT_VAR); mb_assert(obj->type == _DT_VAR);
result = _internal_object_to_public_value(obj->data.variable->data, val); if(val)
result = _internal_object_to_public_value(obj->data.variable->data, val);
else
result = _internal_object_to_public_value(obj->data.variable->data, &tmp);
} else { } else {
val->type = MB_DT_NIL; if(val)
val->type = MB_DT_NIL;
result = MB_DEBUG_ID_NOT_FOUND; result = MB_DEBUG_ID_NOT_FOUND;
} }