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;
|
||||
}
|
||||
|
||||
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)
|
||||
uiprivInternalError("memory exhausted reallocating %s", what);
|
||||
if (new > old)
|
||||
memset(((uint8_t *) p) + old, 0, new - old);
|
||||
if (nNew > nOld)
|
||||
memset(((uint8_t *) p) + nOld, 0, nNew - nOld);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
// 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 <stdio.h>
|
||||
#include "ui.h"
|
||||
|
|
|
@ -37,7 +37,7 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
|
|||
uiEvent *e;
|
||||
|
||||
if (options == NULL) {
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventOptions", __func__);
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventOptions", uiprivFunc);
|
||||
return NULL;
|
||||
}
|
||||
if (options->Size != sizeof (uiEventOptions)) {
|
||||
|
@ -52,11 +52,11 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
|
|||
}
|
||||
|
||||
#define checkEventNonnull(e, ret) if ((e) == NULL) { \
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEvent", __func__); \
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEvent", uiprivFunc); \
|
||||
return ret; \
|
||||
}
|
||||
#define checkEventNotFiring(e, ret) if ((e)->firing) { \
|
||||
uiprivProgrammerError(uiprivProgrammerErrorChangingEventDuringFire, __func__); \
|
||||
uiprivProgrammerError(uiprivProgrammerErrorChangingEventDuringFire, uiprivFunc); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
|
@ -81,10 +81,10 @@ int uiEventAddHandler(uiEvent *e, uiEventHandler handler, void *sender, void *da
|
|||
checkEventNonnull(e, 0);
|
||||
checkEventNotFiring(e, 0);
|
||||
if (handler == NULL) {
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventHandler", __func__);
|
||||
uiprivProgrammerError(uiprivProgrammerErrorNullPointer, "uiEventHandler", uiprivFunc);
|
||||
return 0;
|
||||
}
|
||||
if (!checkEventSender(e, sender, __func__))
|
||||
if (!checkEventSender(e, sender, uiprivFunc))
|
||||
return 0;
|
||||
|
||||
id = 0;
|
||||
|
@ -125,7 +125,7 @@ void uiEventDeleteHandler(uiEvent *e, int id)
|
|||
|
||||
checkEventNonnull(e, /* nothing */);
|
||||
checkEventNotFiring(e, /* nothing */);
|
||||
h = findHandler(e, id, __func__);
|
||||
h = findHandler(e, id, uiprivFunc);
|
||||
if (h == NULL)
|
||||
return;
|
||||
|
||||
|
@ -143,7 +143,7 @@ void uiEventFire(uiEvent *e, void *sender, void *args)
|
|||
uiprivProgrammerError(uiprivProgrammerErrorRecursiveEventFire);
|
||||
return;
|
||||
}
|
||||
if (!checkEventSender(e, sender, __func__))
|
||||
if (!checkEventSender(e, sender, uiprivFunc))
|
||||
return;
|
||||
|
||||
e->firing = true;
|
||||
|
@ -161,7 +161,7 @@ bool uiEventHandlerBlocked(const uiEvent *e, int id)
|
|||
struct handler *h;
|
||||
|
||||
checkEventNonnull(e, false);
|
||||
h = findHandler(e, id, __func__);
|
||||
h = findHandler(e, id, uiprivFunc);
|
||||
if (h == NULL)
|
||||
return false;
|
||||
return h->blocked;
|
||||
|
@ -173,7 +173,7 @@ void uiEventSetHandlerBlocked(uiEvent *e, int id, bool blocked)
|
|||
|
||||
checkEventNonnull(e, /* nothing */);
|
||||
checkEventNotFiring(e, /* nothing */);
|
||||
h = findHandler(e, id, __func__);
|
||||
h = findHandler(e, id, uiprivFunc);
|
||||
if (h == NULL)
|
||||
return;
|
||||
h->blocked = blocked;
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
extern "C" {
|
||||
#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
|
||||
extern const char **uiprivSysInitErrors(void);
|
||||
extern int uiprivSysInit(void *options, uiInitError *err);
|
||||
|
@ -12,7 +19,7 @@ extern int uiprivInitReturnErrorf(uiInitError *err, const char *msg, ...);
|
|||
|
||||
// alloc.c
|
||||
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);
|
||||
typedef struct uiprivArray uiprivArray;
|
||||
struct uiprivArray {
|
||||
|
@ -44,12 +51,12 @@ extern void uiprivArrayQsort(uiprivArray *arr, int (*compare)(const void *, cons
|
|||
extern void uiprivInternalError(const char *fmt, ...);
|
||||
enum {
|
||||
uiprivProgrammerErrorWrongStructSize, // arguments: size_t badSize, const char *structName
|
||||
uiprivProgrammerErrorIndexOutOfRange, // arguments: int badIndex, __func__
|
||||
uiprivProgrammerErrorNullPointer, // arguments: const char *paramDesc, __func__
|
||||
uiprivProgrammerErrorIntIDNotFound, // arguments: const char *idDesc, int badID, __func__
|
||||
uiprivProgrammerErrorIndexOutOfRange, // arguments: int badIndex, uiprivFunc
|
||||
uiprivProgrammerErrorNullPointer, // arguments: const char *paramDesc, uiprivFunc
|
||||
uiprivProgrammerErrorIntIDNotFound, // arguments: const char *idDesc, int badID, uiprivFunc
|
||||
// TODO type mismatch
|
||||
uiprivProgrammerErrorBadSenderForEvent, // arguments: const char *senderDesc, const char *eventDesc, __func__
|
||||
uiprivProgrammerErrorChangingEventDuringFire, // arguments: __func__
|
||||
uiprivProgrammerErrorBadSenderForEvent, // arguments: const char *senderDesc, const char *eventDesc, uiprivFunc
|
||||
uiprivProgrammerErrorChangingEventDuringFire, // arguments: uiprivFunc
|
||||
uiprivProgrammerErrorRecursiveEventFire, // no arguments
|
||||
uiprivNumProgrammerErrors,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
// 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -28,13 +32,13 @@ void *testingprivAlloc(size_t n, const char *what)
|
|||
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)
|
||||
testingprivInternalError("memory exhausted reallocating %s", what);
|
||||
if (new > old)
|
||||
memset(((uint8_t *) p) + old, 0, new - old);
|
||||
if (nNew > nOld)
|
||||
memset(((uint8_t *) p) + nOld, 0, nNew - nOld);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -223,7 +227,7 @@ void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src)
|
|||
char *buf;
|
||||
size_t n;
|
||||
int hasTrailingBlankLine;
|
||||
size_t trailingBlankLinePos;
|
||||
size_t trailingBlankLinePos = 0; // silence incorrect MSVC warning
|
||||
char *lineStart, *lineEnd;
|
||||
|
||||
buf = src->buf.buf;
|
||||
|
|
|
@ -5,7 +5,7 @@ extern void testingprivInternalError(const char *fmt, ...);
|
|||
extern void *testingprivAlloc(size_t n, const char *what);
|
||||
#define testingprivNew(T) ((T *) testingprivAlloc(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 "[]"))
|
||||
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
|
||||
#ifndef RC_INVOKED
|
||||
#include <commctrl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue