-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer.h
33 lines (24 loc) · 826 Bytes
/
buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef BUFF_H
#define BUFF_H
// the line editor buffer
typedef struct ldBuffer {
char * strBuf;
int capacity;
int startIndex;
int endIndex;
//Todo move the start and end index fields over here from the main program; that is better localization
} ldBuffer;
/*Adds character to buffer at the given index*/
void insertChar(ldBuffer * ldBuf, char c, int index);
/*Removes the char at the given index*/
void removeChar(ldBuffer * ldBuf, int index);
/*The given pointer will be made to point to this buffers*/
char * toString(ldBuffer * ldBuf);
/*Returns the size of the buffer*/
int size(ldBuffer * ldBuf);
/*initiates and returns a pointer to an ld buffer; takes initial capacity*/
void initLDBuff(ldBuffer ** ldb, int initCapacity);
#endif