… | |
… | |
28 | |
28 | |
29 | faceidx blank_face, empty_face, magicmouth_face; |
29 | faceidx blank_face, empty_face, magicmouth_face; |
30 | |
30 | |
31 | facehash_t facehash; |
31 | facehash_t facehash; |
32 | std::vector<faceinfo> faces; |
32 | std::vector<faceinfo> faces; |
|
|
33 | |
|
|
34 | static std::vector<faceidx> faces_free; |
|
|
35 | |
|
|
36 | faceidx face_alloc () |
|
|
37 | { |
|
|
38 | faceidx idx; |
|
|
39 | |
|
|
40 | if (faces_freelist.empty ()) |
|
|
41 | { |
|
|
42 | idx = faces_free.back (); |
|
|
43 | faces_free.pop_back (); |
|
|
44 | } |
|
|
45 | else |
|
|
46 | { |
|
|
47 | idx = faces.size (); |
|
|
48 | |
|
|
49 | if (!idx) // skip index 0 |
|
|
50 | idx = 1; |
|
|
51 | |
|
|
52 | faces.resize (idx + 1); |
|
|
53 | } |
|
|
54 | |
|
|
55 | return idx; |
|
|
56 | } |
|
|
57 | |
|
|
58 | faceinfo::unref () |
|
|
59 | { |
|
|
60 | if (--refcnt) |
|
|
61 | return; |
|
|
62 | |
|
|
63 | refcnt = 1; |
|
|
64 | |
|
|
65 | } |
33 | |
66 | |
34 | faceidx |
67 | faceidx |
35 | face_find (const char *name, faceidx defidx) |
68 | face_find (const char *name, faceidx defidx) |
36 | { |
69 | { |
37 | if (!name) |
70 | if (!name) |