mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Fixed crash in hmap_* functions
This commit is contained in:
parent
97ea7780c8
commit
6d89c6e173
2 changed files with 10 additions and 0 deletions
|
@ -16,6 +16,7 @@ void* hmap_create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* hmap_get(void* map, int64_t k) {
|
void* hmap_get(void* map, int64_t k) {
|
||||||
|
if (!map) { return NULL; }
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
Map::iterator pos = m->find(k);
|
Map::iterator pos = m->find(k);
|
||||||
if (pos == m->end()) {
|
if (pos == m->end()) {
|
||||||
|
@ -26,6 +27,7 @@ void* hmap_get(void* map, int64_t k) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void hmap_put(void* map, int64_t k, void* v) {
|
void hmap_put(void* map, int64_t k, void* v) {
|
||||||
|
if (!map) { return; }
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
if (m->count(k) > 0) {
|
if (m->count(k) > 0) {
|
||||||
m->erase(k);
|
m->erase(k);
|
||||||
|
@ -34,21 +36,25 @@ void hmap_put(void* map, int64_t k, void* v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void hmap_del(void* map, int64_t k) {
|
void hmap_del(void* map, int64_t k) {
|
||||||
|
if (!map) { return; }
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
m->erase(k);
|
m->erase(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hmap_clear(void* map) {
|
void hmap_clear(void* map) {
|
||||||
|
if (!map) { return; }
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
m->clear();
|
m->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hmap_len(void* map) {
|
size_t hmap_len(void* map) {
|
||||||
|
if (!map) { return 0; }
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
return m->size();
|
return m->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* hmap_iter(void* map) {
|
void* hmap_iter(void* map) {
|
||||||
|
if (!map) { return nullptr; }
|
||||||
auto iter = new MapIter();
|
auto iter = new MapIter();
|
||||||
Map* m = reinterpret_cast<Map*> (map);
|
Map* m = reinterpret_cast<Map*> (map);
|
||||||
iter->map = m;
|
iter->map = m;
|
||||||
|
@ -56,6 +62,7 @@ void* hmap_iter(void* map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* hmap_begin(void* iter) {
|
void* hmap_begin(void* iter) {
|
||||||
|
if (!iter) { return nullptr; }
|
||||||
MapIter* i = reinterpret_cast<MapIter*> (iter);
|
MapIter* i = reinterpret_cast<MapIter*> (iter);
|
||||||
i->itr = i->map->begin();
|
i->itr = i->map->begin();
|
||||||
if (i->itr == i->map->end()) {
|
if (i->itr == i->map->end()) {
|
||||||
|
@ -65,6 +72,7 @@ void* hmap_begin(void* iter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* hmap_next(void* iter) {
|
void* hmap_next(void* iter) {
|
||||||
|
if (!iter) { return nullptr; }
|
||||||
MapIter* i = reinterpret_cast<MapIter*> (iter);
|
MapIter* i = reinterpret_cast<MapIter*> (iter);
|
||||||
i->itr++;
|
i->itr++;
|
||||||
if (i->itr == i->map->end()) {
|
if (i->itr == i->map->end()) {
|
||||||
|
|
|
@ -286,6 +286,8 @@ u32 djui_unicode_get_sprite_index(char* text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 djui_unicode_get_sprite_width(char* text, const f32 font_widths[]) {
|
f32 djui_unicode_get_sprite_width(char* text, const f32 font_widths[]) {
|
||||||
|
if (!text) { return 0; }
|
||||||
|
|
||||||
// check for ASCI
|
// check for ASCI
|
||||||
if ((u8)*text < 128) {
|
if ((u8)*text < 128) {
|
||||||
// make sure it's in the valid range
|
// make sure it's in the valid range
|
||||||
|
|
Loading…
Reference in a new issue