Fixed most errors.

This commit is contained in:
Pietro Gagliardi 2015-04-22 17:54:05 -04:00
parent f5fa6eb2c7
commit db3fe82554
7 changed files with 66 additions and 7 deletions

View File

@ -38,7 +38,7 @@ static void boxDestroy(uiControl *c)
uiControlSetHasParent(b->controls[i].c, 0);
uiControlSetOSContainer(b->controls[i].c, NULL);
uiControlDestroy(b->controls[i].c);
{
}
uiFree(b->controls);
uiFree(b);
}
@ -64,7 +64,7 @@ static void boxSetOSContainer(uiControl *c, uiOSContainer *osContainer)
oldcontainer = b->osContainer;
b->osContainer = osContainer;
for (i = 0; i < b->len; i++)
uiControlSetParent(b->controls[i].c, b->osContainer);
uiControlSetOSContainer(b->controls[i].c, b->osContainer);
if (oldcontainer != NULL)
uiOSContainerUpdate(oldcontainer);
if (b->osContainer != NULL)
@ -325,7 +325,7 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
b->cap += boxCapGrow;
b->controls = (boxControl *) uiRealloc(b->controls, b->cap * sizeof (boxControl), "boxControl[]");
}
uiControlSethasParent(c, 1);
uiControlSetHasParent(c, 1);
b->controls[b->len].c = c;
b->controls[b->len].stretchy = stretchy;
b->len++; // must be here for OS container updates to work

View File

@ -1,6 +1,12 @@
// 22 april 2015
#include "test.h"
void die(const char *fmt, ...)
{
// TODO
abort();
}
int main(void)
{
printf("hello, world %p\n", uiMain);

View File

@ -10,13 +10,13 @@ static struct thing *things = NULL;
static uintmax_t len = 0;
static uintmax_t cap = 0;
#define incr 32
#define grow 32
static void *append(void *thing, int type)
{
if (len >= cap) {
cap += grow;
things = (struct thing *) realloc(uiBoxes, cap * sizeof (struct thing));
things = (struct thing *) realloc(things, cap * sizeof (struct thing));
if (things == NULL)
die("reallocating things array in test/spaced.c append()");
}
@ -38,7 +38,7 @@ void setSpaced(int spaced)
for (i = 0; i < len; i++) {
p = things[i].ptr;
switch (things[i],type) {
switch (things[i].type) {
case window:
uiWindowSetMargined(uiWindow(p), spaced);
break;

View File

@ -1,8 +1,13 @@
// 22 april 2015
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include "../ui.h"
// main.c
extern void die(const char *, ...);
// spaced.c
extern void setSpaced(int);
extern uiBox *newHorizontalBox(void);

View File

@ -1,7 +1,9 @@
# 22 april 2015
osCFILES = \
unix/main.c
unix/alloc.c \
unix/main.c \
unix/util.c
osHFILES = \
unix/uipriv_unix.h

33
new/unix/alloc.c Normal file
View File

@ -0,0 +1,33 @@
// 7 april 2015
#include <stdio.h>
#include "uipriv_unix.h"
void *uiAlloc(size_t size, const char *type)
{
void *out;
out = g_malloc0(size);
if (options.debugLogAllocations)
fprintf(stderr, "%p alloc %s\n", out, type);
return out;
}
void *uiRealloc(void *p, size_t size, const char *type)
{
void *out;
if (p == NULL)
return uiAlloc(size, type);
// TODO fill with 0s
out = g_realloc(p, size);
if (options.debugLogAllocations)
fprintf(stderr, "%p realloc %p\n", p, out);
return out;
}
void uiFree(void *p)
{
g_free(p);
if (options.debugLogAllocations)
fprintf(stderr, "%p free\n", p);
}

13
new/unix/util.c Normal file
View File

@ -0,0 +1,13 @@
// 18 april 2015
#include "uipriv_unix.h"
void complain(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
// there's no g_errorv() in glib 2.32, so do it manually instead
g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, fmt, ap);
va_end(ap);
abort(); // just in case
}