Lines Matching refs:device

46 mbfl_memory_device_init(mbfl_memory_device *device, size_t initsz, size_t allocsz)  in mbfl_memory_device_init()  argument
48 if (device) { in mbfl_memory_device_init()
49 device->length = 0; in mbfl_memory_device_init()
50 device->buffer = NULL; in mbfl_memory_device_init()
52 device->buffer = (unsigned char *)mbfl_malloc(initsz); in mbfl_memory_device_init()
53 if (device->buffer != NULL) { in mbfl_memory_device_init()
54 device->length = initsz; in mbfl_memory_device_init()
57 device->pos = 0; in mbfl_memory_device_init()
59 device->allocsz = allocsz; in mbfl_memory_device_init()
61 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_init()
67 mbfl_memory_device_realloc(mbfl_memory_device *device, size_t initsz, size_t allocsz) in mbfl_memory_device_realloc() argument
71 if (device) { in mbfl_memory_device_realloc()
72 if (initsz > device->length) { in mbfl_memory_device_realloc()
73 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, initsz); in mbfl_memory_device_realloc()
75 device->buffer = tmp; in mbfl_memory_device_realloc()
76 device->length = initsz; in mbfl_memory_device_realloc()
80 device->allocsz = allocsz; in mbfl_memory_device_realloc()
82 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_realloc()
88 mbfl_memory_device_clear(mbfl_memory_device *device) in mbfl_memory_device_clear() argument
90 if (device) { in mbfl_memory_device_clear()
91 if (device->buffer) { in mbfl_memory_device_clear()
92 mbfl_free(device->buffer); in mbfl_memory_device_clear()
94 device->buffer = NULL; in mbfl_memory_device_clear()
95 device->length = 0; in mbfl_memory_device_clear()
96 device->pos = 0; in mbfl_memory_device_clear()
101 mbfl_memory_device_reset(mbfl_memory_device *device) in mbfl_memory_device_reset() argument
103 if (device) { in mbfl_memory_device_reset()
104 device->pos = 0; in mbfl_memory_device_reset()
109 mbfl_memory_device_unput(mbfl_memory_device *device) in mbfl_memory_device_unput() argument
111 if (device->pos > 0) { in mbfl_memory_device_unput()
112 device->pos--; in mbfl_memory_device_unput()
117 mbfl_memory_device_result(mbfl_memory_device *device, mbfl_string *result) in mbfl_memory_device_result() argument
119 if (device && result) { in mbfl_memory_device_result()
120 result->len = device->pos; in mbfl_memory_device_result()
121 mbfl_memory_device_output('\0', device); in mbfl_memory_device_result()
122 result->val = device->buffer; in mbfl_memory_device_result()
123 device->buffer = NULL; in mbfl_memory_device_result()
124 device->length = 0; in mbfl_memory_device_result()
125 device->pos= 0; in mbfl_memory_device_result()
140 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output() local
142 if (device->pos >= device->length) { in mbfl_memory_device_output()
147 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_memory_device_output()
152 newlen = device->length + device->allocsz; in mbfl_memory_device_output()
153 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen); 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 (2 > device->length - device->pos) { in mbfl_memory_device_output2()
175 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_memory_device_output2()
180 newlen = device->length + device->allocsz; in mbfl_memory_device_output2()
181 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen); in mbfl_memory_device_output2()
185 device->length = newlen; in mbfl_memory_device_output2()
186 device->buffer = tmp; in mbfl_memory_device_output2()
189 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output2()
190 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output2()
198 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output4() local
200 if (4 > device->length - device->pos) { in mbfl_memory_device_output4()
205 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_memory_device_output4()
210 newlen = device->length + device->allocsz; in mbfl_memory_device_output4()
211 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen); in mbfl_memory_device_output4()
215 device->length = newlen; in mbfl_memory_device_output4()
216 device->buffer = tmp; in mbfl_memory_device_output4()
219 device->buffer[device->pos++] = (unsigned char)((c >> 24) & 0xff); in mbfl_memory_device_output4()
220 device->buffer[device->pos++] = (unsigned char)((c >> 16) & 0xff); in mbfl_memory_device_output4()
221 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output4()
222 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output4()
228 mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc) in mbfl_memory_device_strcat() argument
230 return mbfl_memory_device_strncat(device, psrc, strlen(psrc)); in mbfl_memory_device_strcat()
234 mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, size_t len) in mbfl_memory_device_strncat() argument
238 if (len > device->length - device->pos) { in mbfl_memory_device_strncat()
244 || device->length > SIZE_MAX - (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)) { in mbfl_memory_device_strncat()
249 newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_strncat()
250 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen); in mbfl_memory_device_strncat()
255 device->length = newlen; in mbfl_memory_device_strncat()
256 device->buffer = tmp; in mbfl_memory_device_strncat()
259 w = &device->buffer[device->pos]; in mbfl_memory_device_strncat()
261 device->pos += len; in mbfl_memory_device_strncat()
273 mbfl_wchar_device_init(mbfl_wchar_device *device) in mbfl_wchar_device_init() argument
275 if (device) { in mbfl_wchar_device_init()
276 device->buffer = NULL; in mbfl_wchar_device_init()
277 device->length = 0; in mbfl_wchar_device_init()
278 device->pos= 0; in mbfl_wchar_device_init()
279 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_wchar_device_init()
284 mbfl_wchar_device_clear(mbfl_wchar_device *device) in mbfl_wchar_device_clear() argument
286 if (device) { in mbfl_wchar_device_clear()
287 if (device->buffer) { in mbfl_wchar_device_clear()
288 mbfl_free(device->buffer); in mbfl_wchar_device_clear()
290 device->buffer = NULL; in mbfl_wchar_device_clear()
291 device->length = 0; in mbfl_wchar_device_clear()
292 device->pos = 0; in mbfl_wchar_device_clear()
299 mbfl_wchar_device *device = (mbfl_wchar_device *)data; in mbfl_wchar_device_output() local
301 if (device->pos >= device->length) { in mbfl_wchar_device_output()
306 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_wchar_device_output()
311 newlen = device->length + device->allocsz; in mbfl_wchar_device_output()
317 tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int)); in mbfl_wchar_device_output()
321 device->length = newlen; in mbfl_wchar_device_output()
322 device->buffer = tmp; in mbfl_wchar_device_output()
325 device->buffer[device->pos++] = c; in mbfl_wchar_device_output()