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()
149 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output()
153 device->length = newlen; in mbfl_memory_device_output()
154 device->buffer = tmp; in mbfl_memory_device_output()
157 device->buffer[device->pos++] = (unsigned char)c; in mbfl_memory_device_output()
164 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output2() local
166 if ((device->pos + 2) >= device->length) { in mbfl_memory_device_output2()
171 newlen = device->length + device->allocsz; in mbfl_memory_device_output2()
172 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output2()
176 device->length = newlen; in mbfl_memory_device_output2()
177 device->buffer = tmp; in mbfl_memory_device_output2()
180 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output2()
181 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output2()
189 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output4() local
191 if ((device->pos + 4) >= device->length) { in mbfl_memory_device_output4()
196 newlen = device->length + device->allocsz; in mbfl_memory_device_output4()
197 tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char)); in mbfl_memory_device_output4()
201 device->length = newlen; in mbfl_memory_device_output4()
202 device->buffer = tmp; in mbfl_memory_device_output4()
205 device->buffer[device->pos++] = (unsigned char)((c >> 24) & 0xff); in mbfl_memory_device_output4()
206 device->buffer[device->pos++] = (unsigned char)((c >> 16) & 0xff); in mbfl_memory_device_output4()
207 device->buffer[device->pos++] = (unsigned char)((c >> 8) & 0xff); in mbfl_memory_device_output4()
208 device->buffer[device->pos++] = (unsigned char)(c & 0xff); in mbfl_memory_device_output4()
214 mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc) in mbfl_memory_device_strcat() argument
227 if ((device->pos + len) >= device->length) { in mbfl_memory_device_strcat()
229 int newlen = device->length + (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)*sizeof(unsigned char); in mbfl_memory_device_strcat()
230 …unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned … in mbfl_memory_device_strcat()
234 device->length = newlen; in mbfl_memory_device_strcat()
235 device->buffer = tmp; in mbfl_memory_device_strcat()
239 w = &device->buffer[device->pos]; in mbfl_memory_device_strcat()
240 device->pos += len; in mbfl_memory_device_strcat()
250 mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, int len) in mbfl_memory_device_strncat() argument
254 if ((device->pos + len) >= device->length) { in mbfl_memory_device_strncat()
256 int newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_strncat()
257 …unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned … in mbfl_memory_device_strncat()
261 device->length = newlen; in mbfl_memory_device_strncat()
262 device->buffer = tmp; in mbfl_memory_device_strncat()
265 w = &device->buffer[device->pos]; in mbfl_memory_device_strncat()
266 device->pos += len; in mbfl_memory_device_strncat()
305 mbfl_wchar_device_init(mbfl_wchar_device *device) in mbfl_wchar_device_init() argument
307 if (device) { in mbfl_wchar_device_init()
308 device->buffer = (unsigned int *)0; in mbfl_wchar_device_init()
309 device->length = 0; in mbfl_wchar_device_init()
310 device->pos= 0; in mbfl_wchar_device_init()
311 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_wchar_device_init()
316 mbfl_wchar_device_clear(mbfl_wchar_device *device) in mbfl_wchar_device_clear() argument
318 if (device) { in mbfl_wchar_device_clear()
319 if (device->buffer) { in mbfl_wchar_device_clear()
320 mbfl_free(device->buffer); in mbfl_wchar_device_clear()
322 device->buffer = (unsigned int*)0; in mbfl_wchar_device_clear()
323 device->length = 0; in mbfl_wchar_device_clear()
324 device->pos = 0; in mbfl_wchar_device_clear()
331 mbfl_wchar_device *device = (mbfl_wchar_device *)data; in mbfl_wchar_device_output() local
333 if (device->pos >= device->length) { in mbfl_wchar_device_output()
338 newlen = device->length + device->allocsz; in mbfl_wchar_device_output()
339 tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int)); in mbfl_wchar_device_output()
343 device->length = newlen; in mbfl_wchar_device_output()
344 device->buffer = tmp; in mbfl_wchar_device_output()
347 device->buffer[device->pos++] = c; in mbfl_wchar_device_output()