diff options
Diffstat (limited to 'src/lib/libkogata')
-rw-r--r-- | src/lib/libkogata/draw.c | 6 | ||||
-rw-r--r-- | src/lib/libkogata/malloc.c | 10 | ||||
-rw-r--r-- | src/lib/libkogata/unistd.c | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/libkogata/draw.c b/src/lib/libkogata/draw.c index 53070ad..2806df4 100644 --- a/src/lib/libkogata/draw.c +++ b/src/lib/libkogata/draw.c @@ -88,7 +88,7 @@ void g_hline(fb_t *fb, int x, int y, int w, color_t c) { for (int u = x; u < x + w; u++) { fb->data[y * fb->geom.pitch + u] = (c & 0xFF); } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int u = x; u < x + w; u++) { uint16_t *p = (uint16_t*)(fb->data + y * fb->geom.pitch + 2 * u); *p = (c & 0xFFFF); @@ -110,7 +110,7 @@ void g_vline(fb_t *fb, int x, int y, int h, color_t c) { for (int v = y; v < y + h; v++) { fb->data[v * fb->geom.pitch + x] = (c & 0xFF); } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int v = y; v < y + h; v++) { uint16_t *p = (uint16_t*)(fb->data + v * fb->geom.pitch + 2 * x); *p = (c & 0xFFFF); @@ -145,7 +145,7 @@ void g_fillrect(fb_t *fb, int x, int y, int w, int h, color_t c) { fb->data[v * fb->geom.pitch + u] = (c & 0xFF); } } - } else if (fb->geom.bpp == 15 || fb->geom.bpp == 15) { + } else if (fb->geom.bpp == 15 || fb->geom.bpp == 16) { for (int v = y; v < y + h; v++) { for (int u = x; u < x + w; u++) { uint16_t *p = (uint16_t*)(fb->data + v * fb->geom.pitch + 2 * u); diff --git a/src/lib/libkogata/malloc.c b/src/lib/libkogata/malloc.c index 2a3345f..3777123 100644 --- a/src/lib/libkogata/malloc.c +++ b/src/lib/libkogata/malloc.c @@ -1,6 +1,8 @@ #include <malloc.h> #include <slab_alloc.h> +#include <string.h> + #include <syscall.h> #include <region_alloc.h> @@ -50,9 +52,17 @@ void malloc_setup() { } void* malloc(size_t size) { + if (size == 0) return 0; + return slab_alloc(mem_allocator, size); } +void* calloc(size_t nmemb, size_t sz) { + void* r = malloc(nmemb * sz); + if (r != 0) memset(r, 0, nmemb * sz); + return r; +} + void free(void* ptr) { slab_free(mem_allocator, ptr); } diff --git a/src/lib/libkogata/unistd.c b/src/lib/libkogata/unistd.c index 80a32e4..101e02e 100644 --- a/src/lib/libkogata/unistd.c +++ b/src/lib/libkogata/unistd.c @@ -24,7 +24,7 @@ int chdir(const char* path) { stat_t st; if (!stat(cwd_buf2, &st)) return -1; - if (!st.type & FT_DIR) return -1; + if (!(st.type & FT_DIR)) return -1; strcpy(cwd_buf, cwd_buf2); return 0; |