trunk/src/emu/netlist/pstring.h
| r26535 | r26536 | |
| 8 | 8 | #define _PSTRING_H_ |
| 9 | 9 | |
| 10 | 10 | #include "nl_config.h" |
| 11 | #include <cstdio> |
| 11 | 12 | |
| 12 | 13 | // ---------------------------------------------------------------------------------------- |
| 13 | 14 | // pblockbool: allocate small memory more efficiently at the expense of some overhead |
| r26535 | r26536 | |
| 50 | 51 | inline void *operator new(std::size_t size, pblockpool &pool, int extra = 0) throw (std::bad_alloc) |
| 51 | 52 | { |
| 52 | 53 | void *result = pool.alloc(size + extra); |
| 54 | //std::printf("allocating %ld + %d\n", size, extra); |
| 53 | 55 | if (result == NULL) |
| 54 | 56 | throw std::bad_alloc(); |
| 55 | 57 | return result; |
| r26535 | r26536 | |
| 133 | 135 | |
| 134 | 136 | pstring left(unsigned int count) const { return substr(0, count); } |
| 135 | 137 | pstring right(unsigned int count) const { return substr(len() - count, count); } |
| 138 | pstring ucase() const; |
| 136 | 139 | |
| 137 | 140 | // printf using string as format ... |
| 138 | 141 | |
| r26535 | r26536 | |
| 164 | 167 | inline void init() |
| 165 | 168 | { |
| 166 | 169 | if (m_zero == NULL) |
| 170 | { |
| 167 | 171 | m_zero = new(pstring::m_pool, 0) pstring::str_t(0); |
| 172 | } |
| 168 | 173 | m_ptr = m_zero; |
| 169 | 174 | m_ptr->m_ref_count++; |
| 170 | 175 | } |
trunk/src/emu/netlist/pstring.c
| r26535 | r26536 | |
| 59 | 59 | return ret; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | pstring pstring::ucase() const |
| 63 | { |
| 64 | pstring ret = *this; |
| 65 | ret.pcopy(cstr(), len()); |
| 66 | for (int i=0; i<ret.len(); i++) |
| 67 | ret.m_ptr->m_str[i] = toupper((unsigned) ret.m_ptr->m_str[i]); |
| 68 | return ret; |
| 69 | } |
| 70 | |
| 62 | 71 | //------------------------------------------------- |
| 63 | 72 | // pcmpi - compare a character array to an nstring |
| 64 | 73 | //------------------------------------------------- |
| r26535 | r26536 | |
| 101 | 110 | |
| 102 | 111 | pstring::str_t *pstring::salloc(int n) |
| 103 | 112 | { |
| 104 | | str_t *ret = new(m_pool, n) str_t(n); |
| 113 | str_t *ret = new(m_pool, n+1) str_t(n); |
| 105 | 114 | return ret; |
| 106 | 115 | } |
| 107 | 116 | |