Repositories » libk0
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

tip Removed unused intefaces

Changeset ee696ebadee3

Parent 44b9d8052cf8

by Rup Palchowdhury

Changes to 4 files · Browse files at ee696ebadee3 Showing diff from parent 44b9d8052cf8 Diff from another changeset...

Change 1 of 1 Show Entire File kbuffer.c Stacked
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,62 +0,0 @@
-#include <stdlib.h> -#include "kbuffer.h" - -Buffer *newbuffer(unsigned n, E_buftype t) -{ - Buffer *buf; - buf = (Buffer *)malloc(sizeof(Buffer)); - if (t == CHARBUF) { - buf->b = (char *)malloc(n); - buf->p = (char *)buf->b; - } - else if (t == INTBUF) { - buf->b = (int *)malloc(n); - buf->p = (int *)buf->b; - } - buf->i = 0; - buf->n = n; - buf->type = t; - return buf; -} - -Buffer *resizebuffer(Buffer *buf, unsigned n) -{ - void *rebuf; - if (buf->type == CHARBUF) { - rebuf = (char *)realloc(buf->b, n); - if (rebuf != NULL) { - buf->b = (char *)rebuf; - buf->p = (char *)buf->b + buf->i; - buf->n = n; - } - } - else if (buf->type == INTBUF) { - rebuf = (int *)realloc(buf->b, n); - if (rebuf != NULL) { - buf->b = (int *)rebuf; - buf->p = (int *)buf->b + buf->i; - buf->n = n; - } - } - return buf; -} - -void *shiftpointer(Buffer *buf, int shift) -{ - /* TODO: check for invalid shift amounts */ - if (buf->type == CHARBUF) - buf->p = (char *)buf->p + shift; - else if (buf->type == INTBUF) - buf->p = (int *)buf->p + shift; - buf->i += shift; - return buf->p; -} - -void freebuffer(Buffer *buf) -{ - if (buf == NULL) - return; - buf->p = NULL; - free(buf->b); - free(buf); -}
Change 1 of 1 Show Entire File kbuffer.h Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,15 +0,0 @@
-typedef struct Buffer Buffer; -typedef enum {CHARBUF, INTBUF} E_buftype; - -struct Buffer { - void *b; - void *p; - int i; - unsigned n; - E_buftype type; -}; - -Buffer *newbuffer(unsigned, E_buftype); -Buffer *resizebuffer(Buffer*, unsigned); -void *shiftpointer(Buffer*, int); -void freebuffer(Buffer*);
Change 1 of 1 Show Entire File klog.c Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,19 +0,0 @@
-#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include "klog.h" - -Log *newlog(char *prog) -{ - Log *l; - char *s; - time_t t; - - l = (Log *)malloc(sizeof(Log)); - sprintf(l->name, "%s_%lu", prog, (unsigned long)time(NULL)); - strcpy(l->path, "log/"); - strcat(l->path, l->name); - l->fp = fopen(l->path, "w"); - return l; -}
Change 1 of 1 Show Entire File klog.h Stacked
 
1
2
3
4
5
6
7
8
9
 
 
 
 
 
 
 
 
 
 
@@ -1,9 +0,0 @@
-typedef struct Log Log; - -struct Log { - char name[20 + 6 + 1]; - char *path; - FILE *fp; -}; - -Log *newlog(char*);