Entirely forgot what I did

This commit is contained in:
Sasha Koshka 2023-11-07 17:33:53 -05:00
parent e57e93c8b6
commit 1a5c23fd35
2 changed files with 8 additions and 3 deletions

View File

@ -31,6 +31,9 @@ void XmdBufferPeek (XmdBuffer *buffer, Cardinal index, void *element);
returned and must be freed manually using XtFree() at some point. */ returned and must be freed manually using XtFree() at some point. */
void *XmdBufferBreak (XmdBuffer *buffer); void *XmdBufferBreak (XmdBuffer *buffer);
/* XmdBufferLength returns the amount of elements stored in a buffer. */
Cardinal XmdBufferLength (XmdBuffer *buffer);
/* XmdBufferFree frees the buffer and any data associated with it. */ /* XmdBufferFree frees the buffer and any data associated with it. */
void XmdBufferFree (XmdBuffer *buffer); void XmdBufferFree (XmdBuffer *buffer);

View File

@ -40,6 +40,7 @@ void XmdBufferResize (XmdBuffer *buffer, Cardinal length) {
void XmdBufferFit (XmdBuffer *buffer) { void XmdBufferFit (XmdBuffer *buffer) {
if (buffer->length > buffer->capacity) { if (buffer->length > buffer->capacity) {
puts("fitting");
buffer->capacity *= XmdBUFFER_GROWTH_FACTOR; buffer->capacity *= XmdBUFFER_GROWTH_FACTOR;
buffer->data = XtReallocArray ( buffer->data = XtReallocArray (
buffer->data, buffer->data,
@ -70,9 +71,6 @@ void XmdBufferPoke (XmdBuffer *buffer, Cardinal index, void *element) {
XmdBufferOffset(buffer, index), XmdBufferOffset(buffer, index),
element, element,
buffer->size); buffer->size);
char test;
XmdBufferPeek(buffer, index, &test);
} }
void XmdBufferPeek (XmdBuffer *buffer, Cardinal index, void *element) { void XmdBufferPeek (XmdBuffer *buffer, Cardinal index, void *element) {
@ -89,6 +87,10 @@ void *XmdBufferBreak (XmdBuffer *buffer) {
return data; return data;
} }
Cardinal XmdBufferLength (XmdBuffer *buffer) {
return buffer->length;
}
void XmdBufferFree (XmdBuffer *buffer) { void XmdBufferFree (XmdBuffer *buffer) {
if (buffer->data != NULL) { if (buffer->data != NULL) {
XtFree(buffer->data); XtFree(buffer->data);