[PATCH] qbsp: Remove malloc retry logic
If we run out of memory, then too bad. Qbsp never _really_ takes so long that you'd really care too much about starting again. Simplifies portability. Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
parent
b22ed2107a
commit
6bd69a0519
4
Makefile
4
Makefile
|
|
@ -8,12 +8,10 @@ ifeq ($(OSTYPE),msys)
|
|||
EXT=.exe
|
||||
DPTHREAD=
|
||||
LPTHREAD=
|
||||
LCURSES=
|
||||
else
|
||||
EXT=
|
||||
DPTHREAD=-DUSE_PTHREADS
|
||||
LPTHREAD=-lpthread
|
||||
LCURSES=-lcurses
|
||||
endif
|
||||
|
||||
#CFLAGS = -Wall -Werror -g
|
||||
|
|
@ -145,4 +143,4 @@ QBSP_OBJECTS = \
|
|||
qbsp/%.o: CPPFLAGS += -DDOUBLEVEC_T -DQBSP_VERSION=$(QBSP_VERSION)
|
||||
|
||||
qbsp/$(BIN_PFX)qbsp$(EXT): $(patsubst %,qbsp/%,$(QBSP_OBJECTS))
|
||||
$(CC) -o $@ $^ $(LCURSES)
|
||||
$(CC) -o $@ $^
|
||||
|
|
|
|||
27
qbsp/util.c
27
qbsp/util.c
|
|
@ -18,16 +18,6 @@
|
|||
|
||||
See file, 'COPYING', for details.
|
||||
*/
|
||||
// util.c
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <conio.h>
|
||||
# define noecho() do {} while (0)
|
||||
# define echo() do {} while (0)
|
||||
# define getch _getche
|
||||
#else
|
||||
# include <curses.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <malloc.h>
|
||||
|
|
@ -66,24 +56,9 @@ AllocMem(int Type, int cElements, bool fZero)
|
|||
} else
|
||||
cSize = cElements * rgcMemSize[Type];
|
||||
|
||||
Retry:
|
||||
pTemp = malloc(cSize);
|
||||
|
||||
if (pTemp == NULL) {
|
||||
char ch;
|
||||
|
||||
printf
|
||||
("\bOut of memory. Please close some apps and hit 'y' to try again,\n");
|
||||
printf("or any other key to exit -> ");
|
||||
noecho();
|
||||
ch = toupper(getch());
|
||||
echo();
|
||||
printf("\n");
|
||||
fflush(stdin);
|
||||
if (ch == 'Y')
|
||||
goto Retry;
|
||||
if (!pTemp)
|
||||
Message(msgError, errOutOfMemory);
|
||||
}
|
||||
|
||||
if (fZero)
|
||||
memset(pTemp, 0, cSize);
|
||||
|
|
|
|||
Loading…
Reference in New Issue