Fixed build errors. Now to fix runtime errors.
This commit is contained in:
parent
2e82d4aad4
commit
a6c1e1ed17
|
@ -15,13 +15,13 @@ void *uiprivAlloc(size_t n, const char *what)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *uiprivRealloc(void *p, size_t old, size_t new, const char *what)
|
void *uiprivRealloc(void *p, size_t nOld, size_t nNew, const char *what)
|
||||||
{
|
{
|
||||||
p = realloc(p, new);
|
p = realloc(p, nNew);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
uiprivInternalError("memory exhausted reallocating %s", what);
|
uiprivInternalError("memory exhausted reallocating %s", what);
|
||||||
if (new > old)
|
if (nNew > nOld)
|
||||||
memset(((uint8_t *) p) + old, 0, new - old);
|
memset(((uint8_t *) p) + nOld, 0, nNew - nOld);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
// 12 may 2019
|
// 12 may 2019
|
||||||
|
// TODO get rid of the need for this (it temporarily silences noise so I can find actual build issues)
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
|
@ -37,7 +37,7 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
|
||||||
uiEvent *e;
|
uiEvent *e;
|
||||||
|
|
||||||
if (options == NULL) {
|
if (options == NULL) {
|
||||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventOptions", __func__);
|
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventOptions", uiprivFunc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (options->Size != sizeof (uiEventOptions)) {
|
if (options->Size != sizeof (uiEventOptions)) {
|
||||||
|
@ -52,11 +52,11 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkEventNonnull(e, ret) if ((e) == NULL) { \
|
#define checkEventNonnull(e, ret) if ((e) == NULL) { \
|
||||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEvent", __func__); \
|
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEvent", uiprivFunc); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
#define checkEventNotFiring(e, ret) if ((e)->firing) { \
|
#define checkEventNotFiring(e, ret) if ((e)->firing) { \
|
||||||
uiprivProgrammerError(uiprivProgrammerErrorChangingEventDuringFire, __func__); \
|
uiprivProgrammerError(uiprivProgrammerErrorChangingEventDuringFire, uiprivFunc); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ int uiEventAddHandler(uiEvent *e, uiEventHandler handler, void *sender, void *da
|
||||||
checkEventNonnull(e, 0);
|
checkEventNonnull(e, 0);
|
||||||
checkEventNotFiring(e, 0);
|
checkEventNotFiring(e, 0);
|
||||||
if (handler == NULL) {
|
if (handler == NULL) {
|
||||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventHandler", __func__);
|
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventHandler", uiprivFunc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!checkEventSender(e, sender, __func__))
|
if (!checkEventSender(e, sender, uiprivFunc))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -125,7 +125,7 @@ void uiEventDeleteHandler(uiEvent *e, int id)
|
||||||
|
|
||||||
checkEventNonnull(e, /* nothing */);
|
checkEventNonnull(e, /* nothing */);
|
||||||
checkEventNotFiring(e, /* nothing */);
|
checkEventNotFiring(e, /* nothing */);
|
||||||
h = findHandler(e, id, __func__);
|
h = findHandler(e, id, uiprivFunc);
|
||||||
if (h == NULL)
|
if (h == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ void uiEventFire(uiEvent *e, void *sender, void *args)
|
||||||
uiprivProgrammerError(uiprivProgrammerErrorRecursiveEventFire);
|
uiprivProgrammerError(uiprivProgrammerErrorRecursiveEventFire);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!checkEventSender(e, sender, __func__))
|
if (!checkEventSender(e, sender, uiprivFunc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e->firing = true;
|
e->firing = true;
|
||||||
|
@ -161,7 +161,7 @@ bool uiEventHandlerBlocked(const uiEvent *e, int id)
|
||||||
struct handler *h;
|
struct handler *h;
|
||||||
|
|
||||||
checkEventNonnull(e, false);
|
checkEventNonnull(e, false);
|
||||||
h = findHandler(e, id, __func__);
|
h = findHandler(e, id, uiprivFunc);
|
||||||
if (h == NULL)
|
if (h == NULL)
|
||||||
return false;
|
return false;
|
||||||
return h->blocked;
|
return h->blocked;
|
||||||
|
@ -173,7 +173,7 @@ void uiEventSetHandlerBlocked(uiEvent *e, int id, bool blocked)
|
||||||
|
|
||||||
checkEventNonnull(e, /* nothing */);
|
checkEventNonnull(e, /* nothing */);
|
||||||
checkEventNotFiring(e, /* nothing */);
|
checkEventNotFiring(e, /* nothing */);
|
||||||
h = findHandler(e, id, __func__);
|
h = findHandler(e, id, uiprivFunc);
|
||||||
if (h == NULL)
|
if (h == NULL)
|
||||||
return;
|
return;
|
||||||
h->blocked = blocked;
|
h->blocked = blocked;
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO figure out why this is needed despite what https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/b0084kay(v=vs.120) says
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define uiprivFunc __FUNCTION__
|
||||||
|
#else
|
||||||
|
#define uiprivFunc __func__
|
||||||
|
#endif
|
||||||
|
|
||||||
// init.c
|
// init.c
|
||||||
extern const char **uiprivSysInitErrors(void);
|
extern const char **uiprivSysInitErrors(void);
|
||||||
extern int uiprivSysInit(void *options, uiInitError *err);
|
extern int uiprivSysInit(void *options, uiInitError *err);
|
||||||
|
@ -12,7 +19,7 @@ extern int uiprivInitReturnErrorf(uiInitError *err, const char *msg, ...);
|
||||||
|
|
||||||
// alloc.c
|
// alloc.c
|
||||||
extern void *uiprivAlloc(size_t n, const char *what);
|
extern void *uiprivAlloc(size_t n, const char *what);
|
||||||
extern void *uiprivRealloc(void *p, size_t old, size_t new, const char *what);
|
extern void *uiprivRealloc(void *p, size_t nOld, size_t nNew, const char *what);
|
||||||
extern void uiprivFree(void *p);
|
extern void uiprivFree(void *p);
|
||||||
typedef struct uiprivArray uiprivArray;
|
typedef struct uiprivArray uiprivArray;
|
||||||
struct uiprivArray {
|
struct uiprivArray {
|
||||||
|
@ -44,12 +51,12 @@ extern void uiprivArrayQsort(uiprivArray *arr, int (*compare)(const void *, cons
|
||||||
extern void uiprivInternalError(const char *fmt, ...);
|
extern void uiprivInternalError(const char *fmt, ...);
|
||||||
enum {
|
enum {
|
||||||
uiprivProgrammerErrorWrongStructSize, // arguments: size_t badSize, const char *structName
|
uiprivProgrammerErrorWrongStructSize, // arguments: size_t badSize, const char *structName
|
||||||
uiprivProgrammerErrorIndexOutOfRange, // arguments: int badIndex, __func__
|
uiprivProgrammerErrorIndexOutOfRange, // arguments: int badIndex, uiprivFunc
|
||||||
uiprivProgrammerErrorNullPointer, // arguments: const char *paramDesc, __func__
|
uiprivProgrammerErrorNullPointer, // arguments: const char *paramDesc, uiprivFunc
|
||||||
uiprivProgrammerErrorIntIDNotFound, // arguments: const char *idDesc, int badID, __func__
|
uiprivProgrammerErrorIntIDNotFound, // arguments: const char *idDesc, int badID, uiprivFunc
|
||||||
// TODO type mismatch
|
// TODO type mismatch
|
||||||
uiprivProgrammerErrorBadSenderForEvent, // arguments: const char *senderDesc, const char *eventDesc, __func__
|
uiprivProgrammerErrorBadSenderForEvent, // arguments: const char *senderDesc, const char *eventDesc, uiprivFunc
|
||||||
uiprivProgrammerErrorChangingEventDuringFire, // arguments: __func__
|
uiprivProgrammerErrorChangingEventDuringFire, // arguments: uiprivFunc
|
||||||
uiprivProgrammerErrorRecursiveEventFire, // no arguments
|
uiprivProgrammerErrorRecursiveEventFire, // no arguments
|
||||||
uiprivNumProgrammerErrors,
|
uiprivNumProgrammerErrors,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
// 19 may 2019
|
// 19 may 2019
|
||||||
|
// TODO get rid of the need for this (it temporarily silences noise so I can find actual build issues)
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -28,13 +32,13 @@ void *testingprivAlloc(size_t n, const char *what)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *testingprivRealloc(void *p, size_t old, size_t new, const char *what)
|
void *testingprivRealloc(void *p, size_t nOld, size_t nNew, const char *what)
|
||||||
{
|
{
|
||||||
p = realloc(p, new);
|
p = realloc(p, nNew);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
testingprivInternalError("memory exhausted reallocating %s", what);
|
testingprivInternalError("memory exhausted reallocating %s", what);
|
||||||
if (new > old)
|
if (nNew > nOld)
|
||||||
memset(((uint8_t *) p) + old, 0, new - old);
|
memset(((uint8_t *) p) + nOld, 0, nNew - nOld);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +227,7 @@ void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src)
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t n;
|
size_t n;
|
||||||
int hasTrailingBlankLine;
|
int hasTrailingBlankLine;
|
||||||
size_t trailingBlankLinePos;
|
size_t trailingBlankLinePos = 0; // silence incorrect MSVC warning
|
||||||
char *lineStart, *lineEnd;
|
char *lineStart, *lineEnd;
|
||||||
|
|
||||||
buf = src->buf.buf;
|
buf = src->buf.buf;
|
||||||
|
|
|
@ -5,7 +5,7 @@ extern void testingprivInternalError(const char *fmt, ...);
|
||||||
extern void *testingprivAlloc(size_t n, const char *what);
|
extern void *testingprivAlloc(size_t n, const char *what);
|
||||||
#define testingprivNew(T) ((T *) testingprivAlloc(sizeof (T), #T))
|
#define testingprivNew(T) ((T *) testingprivAlloc(sizeof (T), #T))
|
||||||
#define testingprivNewArray(T, n) ((T *) testingprivAlloc(n * sizeof (T), #T "[]"))
|
#define testingprivNewArray(T, n) ((T *) testingprivAlloc(n * sizeof (T), #T "[]"))
|
||||||
extern void *testingprivRealloc(void *p, size_t old, size_t new, const char *what);
|
extern void *testingprivRealloc(void *p, size_t nOld, size_t nNew, const char *what);
|
||||||
#define testingprivResizeArray(x, T, old, new) ((T *) testingprivRealloc(x, old * sizeof (T), new * sizeof (T), #T "[]"))
|
#define testingprivResizeArray(x, T, old, new) ((T *) testingprivRealloc(x, old * sizeof (T), new * sizeof (T), #T "[]"))
|
||||||
extern void testingprivFree(void *p);
|
extern void testingprivFree(void *p);
|
||||||
|
|
||||||
|
|
|
@ -31,4 +31,6 @@
|
||||||
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
||||||
#ifndef RC_INVOKED
|
#ifndef RC_INVOKED
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue