Lines Matching refs:device

41 mbfl_memory_device_init(mbfl_memory_device *device, size_t initsz, size_t allocsz)  in mbfl_memory_device_init()  argument
43 if (device) { in mbfl_memory_device_init()
44 device->length = 0; in mbfl_memory_device_init()
45 device->buffer = NULL; in mbfl_memory_device_init()
47 device->buffer = emalloc(initsz); in mbfl_memory_device_init()
48 device->length = initsz; in mbfl_memory_device_init()
50 device->pos = 0; in mbfl_memory_device_init()
52 device->allocsz = allocsz; in mbfl_memory_device_init()
54 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_init()
60 mbfl_memory_device_realloc(mbfl_memory_device *device, size_t initsz, size_t allocsz) in mbfl_memory_device_realloc() argument
62 if (device) { in mbfl_memory_device_realloc()
63 if (initsz > device->length) { in mbfl_memory_device_realloc()
64 device->buffer = erealloc(device->buffer, initsz); in mbfl_memory_device_realloc()
65 device->length = initsz; in mbfl_memory_device_realloc()
68 device->allocsz = allocsz; in mbfl_memory_device_realloc()
70 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_realloc()
76 mbfl_memory_device_clear(mbfl_memory_device *device) in mbfl_memory_device_clear() argument
78 if (device) { in mbfl_memory_device_clear()
79 if (device->buffer) { in mbfl_memory_device_clear()
80 efree(device->buffer); in mbfl_memory_device_clear()
82 device->buffer = NULL; in mbfl_memory_device_clear()
83 device->length = 0; in mbfl_memory_device_clear()
84 device->pos = 0; in mbfl_memory_device_clear()
89 mbfl_memory_device_reset(mbfl_memory_device *device) in mbfl_memory_device_reset() argument
91 if (device) { in mbfl_memory_device_reset()
92 device->pos = 0; in mbfl_memory_device_reset()
97 mbfl_memory_device_unput(mbfl_memory_device *device) in mbfl_memory_device_unput() argument
99 if (device->pos > 0) { in mbfl_memory_device_unput()
100 device->pos--; in mbfl_memory_device_unput()
105 mbfl_memory_device_result(mbfl_memory_device *device, mbfl_string *result) in mbfl_memory_device_result() argument
107 if (device && result) { in mbfl_memory_device_result()
108 result->len = device->pos; in mbfl_memory_device_result()
109 mbfl_memory_device_output('\0', device); in mbfl_memory_device_result()
110 result->val = device->buffer; in mbfl_memory_device_result()
111 device->buffer = NULL; in mbfl_memory_device_result()
112 device->length = 0; in mbfl_memory_device_result()
113 device->pos= 0; in mbfl_memory_device_result()
128 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output() local
130 if (device->pos >= device->length) { in mbfl_memory_device_output()
134 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_memory_device_output()
139 newlen = device->length + device->allocsz; in mbfl_memory_device_output()
140 device->buffer = erealloc(device->buffer, newlen); in mbfl_memory_device_output()
141 device->length = newlen; in mbfl_memory_device_output()
144 device->buffer[device->pos++] = (unsigned char)c; in mbfl_memory_device_output()
149 mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc) in mbfl_memory_device_strcat() argument
151 return mbfl_memory_device_strncat(device, psrc, strlen(psrc)); in mbfl_memory_device_strcat()
155 mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, size_t len) in mbfl_memory_device_strncat() argument
159 if (len > device->length - device->pos) { in mbfl_memory_device_strncat()
164 || device->length > SIZE_MAX - (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)) { in mbfl_memory_device_strncat()
169 newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_strncat()
170 device->buffer = erealloc(device->buffer, newlen); in mbfl_memory_device_strncat()
171 device->length = newlen; in mbfl_memory_device_strncat()
174 w = &device->buffer[device->pos]; in mbfl_memory_device_strncat()
176 device->pos += len; in mbfl_memory_device_strncat()
188 mbfl_wchar_device_init(mbfl_wchar_device *device) in mbfl_wchar_device_init() argument
190 if (device) { in mbfl_wchar_device_init()
191 device->buffer = NULL; in mbfl_wchar_device_init()
192 device->length = 0; in mbfl_wchar_device_init()
193 device->pos= 0; in mbfl_wchar_device_init()
194 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_wchar_device_init()
199 mbfl_wchar_device_clear(mbfl_wchar_device *device) in mbfl_wchar_device_clear() argument
201 if (device) { in mbfl_wchar_device_clear()
202 if (device->buffer) { in mbfl_wchar_device_clear()
203 efree(device->buffer); in mbfl_wchar_device_clear()
205 device->buffer = NULL; in mbfl_wchar_device_clear()
206 device->length = 0; in mbfl_wchar_device_clear()
207 device->pos = 0; in mbfl_wchar_device_clear()
214 mbfl_wchar_device *device = (mbfl_wchar_device *)data; in mbfl_wchar_device_output() local
216 if (device->pos >= device->length) { in mbfl_wchar_device_output()
220 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_wchar_device_output()
225 newlen = device->length + device->allocsz; in mbfl_wchar_device_output()
231 device->buffer = erealloc(device->buffer, newlen*sizeof(int)); in mbfl_wchar_device_output()
232 device->length = newlen; in mbfl_wchar_device_output()
235 device->buffer[device->pos++] = c; in mbfl_wchar_device_output()