Lines Matching refs:device

40 void mbfl_memory_device_init(mbfl_memory_device *device, size_t initsz, size_t allocsz)  in mbfl_memory_device_init()  argument
42 device->buffer = (initsz > 0) ? emalloc(initsz) : NULL; in mbfl_memory_device_init()
43 device->length = initsz; in mbfl_memory_device_init()
44 device->pos = 0; in mbfl_memory_device_init()
45 device->allocsz = MAX(allocsz, MBFL_MEMORY_DEVICE_ALLOC_SIZE); in mbfl_memory_device_init()
48 void mbfl_memory_device_realloc(mbfl_memory_device *device, size_t initsz, size_t allocsz) in mbfl_memory_device_realloc() argument
50 if (initsz > device->length) { in mbfl_memory_device_realloc()
51 device->buffer = erealloc(device->buffer, initsz); in mbfl_memory_device_realloc()
52 device->length = initsz; in mbfl_memory_device_realloc()
54 device->allocsz = MAX(allocsz, MBFL_MEMORY_DEVICE_ALLOC_SIZE); in mbfl_memory_device_realloc()
57 void mbfl_memory_device_clear(mbfl_memory_device *device) in mbfl_memory_device_clear() argument
59 if (device->buffer) { in mbfl_memory_device_clear()
60 efree(device->buffer); in mbfl_memory_device_clear()
62 device->buffer = NULL; in mbfl_memory_device_clear()
63 device->length = device->pos = 0; in mbfl_memory_device_clear()
66 void mbfl_memory_device_reset(mbfl_memory_device *device) in mbfl_memory_device_reset() argument
68 device->pos = 0; in mbfl_memory_device_reset()
71 void mbfl_memory_device_unput(mbfl_memory_device *device) in mbfl_memory_device_unput() argument
73 if (device->pos > 0) { in mbfl_memory_device_unput()
74 device->pos--; in mbfl_memory_device_unput()
78 mbfl_string* mbfl_memory_device_result(mbfl_memory_device *device, mbfl_string *result) in mbfl_memory_device_result() argument
80 result->len = device->pos; in mbfl_memory_device_result()
81 mbfl_memory_device_output('\0', device); in mbfl_memory_device_result()
82 result->val = device->buffer; in mbfl_memory_device_result()
83 device->buffer = NULL; in mbfl_memory_device_result()
84 device->length = device->pos = 0; in mbfl_memory_device_result()
90 mbfl_memory_device *device = (mbfl_memory_device *)data; in mbfl_memory_device_output() local
92 if (device->pos >= device->length) { in mbfl_memory_device_output()
95 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_memory_device_output()
100 size_t newlen = device->length + device->allocsz; in mbfl_memory_device_output()
101 device->buffer = erealloc(device->buffer, newlen); in mbfl_memory_device_output()
102 device->length = newlen; in mbfl_memory_device_output()
105 device->buffer[device->pos++] = (unsigned char)c; in mbfl_memory_device_output()
109 int mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc) in mbfl_memory_device_strcat() argument
111 return mbfl_memory_device_strncat(device, psrc, strlen(psrc)); in mbfl_memory_device_strcat()
114 int mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, size_t len) in mbfl_memory_device_strncat() argument
116 if (len > device->length - device->pos) { in mbfl_memory_device_strncat()
120 || device->length > SIZE_MAX - (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)) { in mbfl_memory_device_strncat()
125 size_t newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_memory_device_strncat()
126 device->buffer = erealloc(device->buffer, newlen); in mbfl_memory_device_strncat()
127 device->length = newlen; in mbfl_memory_device_strncat()
130 unsigned char *w = &device->buffer[device->pos]; in mbfl_memory_device_strncat()
132 device->pos += len; in mbfl_memory_device_strncat()
142 void mbfl_wchar_device_init(mbfl_wchar_device *device) in mbfl_wchar_device_init() argument
144 device->buffer = NULL; in mbfl_wchar_device_init()
145 device->length = 0; in mbfl_wchar_device_init()
146 device->pos = 0; in mbfl_wchar_device_init()
147 device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; in mbfl_wchar_device_init()
150 void mbfl_wchar_device_clear(mbfl_wchar_device *device) in mbfl_wchar_device_clear() argument
152 if (device->buffer) { in mbfl_wchar_device_clear()
153 efree(device->buffer); in mbfl_wchar_device_clear()
155 device->buffer = NULL; in mbfl_wchar_device_clear()
156 device->length = device->pos = 0; in mbfl_wchar_device_clear()
161 mbfl_wchar_device *device = (mbfl_wchar_device *)data; in mbfl_wchar_device_output() local
163 if (device->pos >= device->length) { in mbfl_wchar_device_output()
167 if (device->length > SIZE_MAX - device->allocsz) { in mbfl_wchar_device_output()
172 newlen = device->length + device->allocsz; in mbfl_wchar_device_output()
178 device->buffer = erealloc(device->buffer, newlen * sizeof(int)); in mbfl_wchar_device_output()
179 device->length = newlen; in mbfl_wchar_device_output()
182 device->buffer[device->pos++] = c; in mbfl_wchar_device_output()