Lines Matching refs:device
47 mbfl_memory_device_init(mbfl_memory_device *device, int initsz, int allocsz) in mbfl_memory_device_init() argument
49 if (device) { in mbfl_memory_device_init()
50 device->length = 0; in mbfl_memory_device_init()
51 device->buffer = (unsigned char *)0; in mbfl_memory_device_init()
53 device->buffer = (unsigned char *)mbfl_malloc(initsz*sizeof(unsigned char)); in mbfl_memory_device_init()
54 if (device->buffer != NULL) { in mbfl_memory_device_init()
55 device->length = initsz; in mbfl_memory_device_init()
58 device->pos= 0; in mbfl_memory_device_init()
60 device->allocsz = allocsz; in mbfl_memory_device_init()
62 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_init()
68 mbfl_memory_device_realloc(mbfl_memory_device *device, int initsz, int allocsz) in mbfl_memory_device_realloc() argument
72 if (device) { in mbfl_memory_device_realloc()
73 if (initsz > device->length) { in mbfl_memory_device_realloc()
74 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, initsz*sizeof(unsigned char)); in mbfl_memory_device_realloc()
76 device->buffer = tmp; in mbfl_memory_device_realloc()
77 device->length = initsz; in mbfl_memory_device_realloc()
81 device->allocsz = allocsz; in mbfl_memory_device_realloc()
83 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_realloc()
89 mbfl_memory_device_clear(mbfl_memory_device *device) in mbfl_memory_device_clear() argument
91 if (device) { in mbfl_memory_device_clear()
92 if (device->buffer) { in mbfl_memory_device_clear()
93 mbfl_free(device->buffer); in mbfl_memory_device_clear()
95 device->buffer = (unsigned char *)0; in mbfl_memory_device_clear()
96 device->length = 0; in mbfl_memory_device_clear()
97 device->pos = 0; in mbfl_memory_device_clear()
102 mbfl_memory_device_reset(mbfl_memory_device *device) in mbfl_memory_device_reset() argument
104 if (device) { in mbfl_memory_device_reset()
105 device->pos = 0; in mbfl_memory_device_reset()
110 mbfl_memory_device_unput(mbfl_memory_device *device) in mbfl_memory_device_unput() argument
112 if (device->pos > 0) { in mbfl_memory_device_unput()
113 device->pos--; in mbfl_memory_device_unput()
118 mbfl_memory_device_result(mbfl_memory_device *device, mbfl_string *result) in mbfl_memory_device_result() argument
120 if (device && result) { in mbfl_memory_device_result()
121 result->len = device->pos; in mbfl_memory_device_result()
122 mbfl_memory_device_output4('\0', device); in mbfl_memory_device_result()
123 result->val = device->buffer; in mbfl_memory_device_result()
124 device->buffer = (unsigned char *)0; in mbfl_memory_device_result()
125 device->length = 0; in mbfl_memory_device_result()
126 device->pos= 0; in mbfl_memory_device_result()
141 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output() local
143 if (device->pos >= device->length) { in mbfl_memory_device_output()
148 newlen = device->length + device->allocsz; in mbfl_memory_device_output()
153 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output()
157 device->length = newlen; in mbfl_memory_device_output()
158 device->buffer = tmp; in mbfl_memory_device_output()
161 device->buffer[device->pos++] = (unsigned char)c; in mbfl_memory_device_output()
168 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output2() local
170 if ((device->pos + 2) >= device->length) { in mbfl_memory_device_output2()
175 newlen = device->length + device->allocsz; in mbfl_memory_device_output2()
180 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output2()
184 device->length = newlen; in mbfl_memory_device_output2()
185 device->buffer = tmp; in mbfl_memory_device_output2()
188 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output2()
189 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output2()
197 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output4() local
199 if ((device->pos + 4) >= device->length) { in mbfl_memory_device_output4()
204 newlen = device->length + device->allocsz; in mbfl_memory_device_output4()
209 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output4()
213 device->length = newlen; in mbfl_memory_device_output4()
214 device->buffer = tmp; in mbfl_memory_device_output4()
217 device->buffer[device->pos++] = (unsigned char)((c >> 24) & 0xff); in mbfl_memory_device_output4()
218 device->buffer[device->pos++] = (unsigned char)((c >> 16) & 0xff); in mbfl_memory_device_output4()
219 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output4()
220 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output4()
226 mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc) in mbfl_memory_device_strcat() argument
239 if ((device->pos + len) >= device->length) { in mbfl_memory_device_strcat()
241 int newlen = device->length + (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)*sizeof(unsigned char); in mbfl_memory_device_strcat()
247 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_strcat()
251 device->length = newlen; in mbfl_memory_device_strcat()
252 device->buffer = tmp; in mbfl_memory_device_strcat()
256 w = &device->buffer[device->pos]; in mbfl_memory_device_strcat()
257 device->pos += len; in mbfl_memory_device_strcat()
267 mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, int len) in mbfl_memory_device_strncat() argument
271 if ((device->pos + len) >= device->length) { in mbfl_memory_device_strncat()
273 int newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_strncat()
279 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_strncat()
283 device->length = newlen; in mbfl_memory_device_strncat()
284 device->buffer = tmp; in mbfl_memory_device_strncat()
287 w = &device->buffer[device->pos]; in mbfl_memory_device_strncat()
288 device->pos += len; in mbfl_memory_device_strncat()
332 mbfl_wchar_device_init(mbfl_wchar_device *device) in mbfl_wchar_device_init() argument
334 if (device) { in mbfl_wchar_device_init()
335 device->buffer = (unsigned int *)0; in mbfl_wchar_device_init()
336 device->length = 0; in mbfl_wchar_device_init()
337 device->pos= 0; in mbfl_wchar_device_init()
338 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_wchar_device_init()
343 mbfl_wchar_device_clear(mbfl_wchar_device *device) in mbfl_wchar_device_clear() argument
345 if (device) { in mbfl_wchar_device_clear()
346 if (device->buffer) { in mbfl_wchar_device_clear()
347 mbfl_free(device->buffer); in mbfl_wchar_device_clear()
349 device->buffer = (unsigned int*)0; in mbfl_wchar_device_clear()
350 device->length = 0; in mbfl_wchar_device_clear()
351 device->pos = 0; in mbfl_wchar_device_clear()
358 mbfl_wchar_device *device = (mbfl_wchar_device *)data; in mbfl_wchar_device_output() local
360 if (device->pos >= device->length) { in mbfl_wchar_device_output()
365 newlen = device->length + device->allocsz; in mbfl_wchar_device_output()
370 tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int)); in mbfl_wchar_device_output()
374 device->length = newlen; in mbfl_wchar_device_output()
375 device->buffer = tmp; in mbfl_wchar_device_output()
378 device->buffer[device->pos++] = c; in mbfl_wchar_device_output()