mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
backup
This commit is contained in:
parent
2404c6fe2b
commit
59e60cf3c0
@ -46,15 +46,16 @@ py_Name py_namev(c11_sv name) {
|
||||
uint64_t hash = c11_sv__hash(name);
|
||||
int index = hash & 0xFFFF;
|
||||
NameBucket* p = pk_string_table.table[index];
|
||||
NameBucket* prev = NULL;
|
||||
bool found = false;
|
||||
while(p) {
|
||||
c11_sv p_sv = {p->data, p->size};
|
||||
if(p->hash == hash && c11__sveq(p_sv, name)) {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
p = p->next;
|
||||
}
|
||||
prev = p;
|
||||
p = p->next;
|
||||
}
|
||||
if(found) {
|
||||
atomic_store(&pk_string_table.lock, false);
|
||||
@ -68,11 +69,11 @@ py_Name py_namev(c11_sv name) {
|
||||
bucket->size = name.size;
|
||||
memcpy(bucket->data, name.data, name.size);
|
||||
bucket->data[name.size] = '\0';
|
||||
if(p == NULL) {
|
||||
if(prev == NULL) {
|
||||
pk_string_table.table[index] = bucket;
|
||||
} else {
|
||||
assert(p->next == NULL);
|
||||
p->next = bucket;
|
||||
assert(prev->next == NULL);
|
||||
prev->next = bucket;
|
||||
}
|
||||
atomic_store(&pk_string_table.lock, false);
|
||||
return (py_Name)bucket;
|
||||
|
@ -225,6 +225,13 @@ char* py_formatexc() {
|
||||
}
|
||||
|
||||
bool py_exception(py_Type type, const char* fmt, ...) {
|
||||
#ifndef NDEBUG
|
||||
if(py_checkexc(true)) {
|
||||
const char* name = py_tpname(pk_current_vm->curr_exception.type);
|
||||
c11__abort("py_exception(): `%s` was already set!", name);
|
||||
}
|
||||
#endif
|
||||
|
||||
c11_sbuf buf;
|
||||
c11_sbuf__ctor(&buf);
|
||||
va_list args;
|
||||
|
Loading…
x
Reference in New Issue
Block a user