Skip to content
Myr

Merge branch 'working'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents 7ed3bb2, 4e8cade · Browse files · 7 files+260 added−99 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+260 added−99 removed

  • tests:+112 added−99 removed
  • other:+148 added−0 removed

7 files+260 added−99 removed

deleted:tests/image_test/image_test.dsp-96 removed
1# Microsoft Developer Studio Project File - Name="image_test" - Package Owner=<4>2# Microsoft Developer Studio Generated Build File, Format Version 6.003# ** DO NOT EDIT **45# TARGTYPE "Win32 (x86) Console Application" 0x010367CFG=image_test - Win32 Debug8!MESSAGE This is not a valid makefile. To build this project using NMAKE,9!MESSAGE use the Export Makefile command and run10!MESSAGE 11!MESSAGE NMAKE /f "image_test.mak".12!MESSAGE 13!MESSAGE You can specify a configuration when running NMAKE14!MESSAGE by defining the macro CFG on the command line. For example:15!MESSAGE 16!MESSAGE NMAKE /f "image_test.mak" CFG="image_test - Win32 Debug"17!MESSAGE 18!MESSAGE Possible choices for configuration are:19!MESSAGE 20!MESSAGE "image_test - Win32 Release" (based on "Win32 (x86) Console Application")21!MESSAGE "image_test - Win32 Debug" (based on "Win32 (x86) Console Application")22!MESSAGE 2324# Begin Project25# PROP AllowPerConfigDependencies 026# PROP Scc_ProjName ""27# PROP Scc_LocalPath ""28CPP=cl.exe29RSC=rc.exe3031!IF "$(CFG)" == "image_test - Win32 Release"3233# PROP BASE Use_MFC 034# PROP BASE Use_Debug_Libraries 035# PROP BASE Output_Dir "Release"36# PROP BASE Intermediate_Dir "Release"37# PROP BASE Target_Dir ""38# PROP Use_MFC 039# PROP Use_Debug_Libraries 040# PROP Output_Dir "Release"41# PROP Intermediate_Dir "Release"42# PROP Target_Dir ""43# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c44# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c45# ADD BASE RSC /l 0x409 /d "NDEBUG"46# ADD RSC /l 0x409 /d "NDEBUG"47BSC32=bscmake.exe48# ADD BASE BSC32 /nologo49# ADD BSC32 /nologo50LINK32=link.exe51# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38652# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I3865354!ELSEIF "$(CFG)" == "image_test - Win32 Debug"5556# PROP BASE Use_MFC 057# PROP BASE Use_Debug_Libraries 158# PROP BASE Output_Dir "Debug"59# PROP BASE Intermediate_Dir "Debug"60# PROP BASE Target_Dir ""61# PROP Use_MFC 062# PROP Use_Debug_Libraries 163# PROP Output_Dir "Debug"64# PROP Intermediate_Dir "Debug"65# PROP Target_Dir ""66# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c67# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c68# ADD BASE RSC /l 0x409 /d "_DEBUG"69# ADD RSC /l 0x409 /d "_DEBUG"70BSC32=bscmake.exe71# ADD BASE BSC32 /nologo72# ADD BSC32 /nologo73LINK32=link.exe74# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept75# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept7677!ENDIF 7879# Begin Target8081# Name "image_test - Win32 Release"82# Name "image_test - Win32 Debug"83# Begin Source File8485SOURCE=..\image_test.c86# End Source File87# Begin Source File8889SOURCE=..\..\stb_image.c90# End Source File91# Begin Source File9293SOURCE=..\..\stb_image_write.h94# End Source File95# End Target96# End Project
added:tests/image_test.dsp+96 added
1# Microsoft Developer Studio Project File - Name="image_test" - Package Owner=<4>2# Microsoft Developer Studio Generated Build File, Format Version 6.003# ** DO NOT EDIT **45# TARGTYPE "Win32 (x86) Console Application" 0x010367CFG=image_test - Win32 Debug8!MESSAGE This is not a valid makefile. To build this project using NMAKE,9!MESSAGE use the Export Makefile command and run10!MESSAGE 11!MESSAGE NMAKE /f "image_test.mak".12!MESSAGE 13!MESSAGE You can specify a configuration when running NMAKE14!MESSAGE by defining the macro CFG on the command line. For example:15!MESSAGE 16!MESSAGE NMAKE /f "image_test.mak" CFG="image_test - Win32 Debug"17!MESSAGE 18!MESSAGE Possible choices for configuration are:19!MESSAGE 20!MESSAGE "image_test - Win32 Release" (based on "Win32 (x86) Console Application")21!MESSAGE "image_test - Win32 Debug" (based on "Win32 (x86) Console Application")22!MESSAGE 2324# Begin Project25# PROP AllowPerConfigDependencies 026# PROP Scc_ProjName ""27# PROP Scc_LocalPath ""28CPP=cl.exe29RSC=rc.exe3031!IF "$(CFG)" == "image_test - Win32 Release"3233# PROP BASE Use_MFC 034# PROP BASE Use_Debug_Libraries 035# PROP BASE Output_Dir "Release"36# PROP BASE Intermediate_Dir "Release"37# PROP BASE Target_Dir ""38# PROP Use_MFC 039# PROP Use_Debug_Libraries 040# PROP Output_Dir "Release"41# PROP Intermediate_Dir "Release"42# PROP Target_Dir ""43# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c44# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c45# ADD BASE RSC /l 0x409 /d "NDEBUG"46# ADD RSC /l 0x409 /d "NDEBUG"47BSC32=bscmake.exe48# ADD BASE BSC32 /nologo49# ADD BSC32 /nologo50LINK32=link.exe51# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I38652# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I3865354!ELSEIF "$(CFG)" == "image_test - Win32 Debug"5556# PROP BASE Use_MFC 057# PROP BASE Use_Debug_Libraries 158# PROP BASE Output_Dir "Debug"59# PROP BASE Intermediate_Dir "Debug"60# PROP BASE Target_Dir ""61# PROP Use_MFC 062# PROP Use_Debug_Libraries 163# PROP Output_Dir "Debug"64# PROP Intermediate_Dir "Debug"65# PROP Target_Dir ""66# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c67# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c68# ADD BASE RSC /l 0x409 /d "_DEBUG"69# ADD RSC /l 0x409 /d "_DEBUG"70BSC32=bscmake.exe71# ADD BASE BSC32 /nologo72# ADD BSC32 /nologo73LINK32=link.exe74# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept75# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept7677!ENDIF 7879# Begin Target8081# Name "image_test - Win32 Release"82# Name "image_test - Win32 Debug"83# Begin Source File8485SOURCE=.\image_test.c86# End Source File87# Begin Source File8889SOURCE=..\stb_image.c90# End Source File91# Begin Source File9293SOURCE=..\..\stb_image_write.h94# End Source File95# End Target96# End Project
modified:tests/stb.c+6 added-1 removed
1550 unmodified lines
1551 // force some memory checking1552 for (n=1; n < 20; ++n)1553 malloc(1 << n);15541555 stb_("Finished stb.c with %d errors.", count);1555 printf("Finished stb.c with %d errors.\n", count);15561557 #ifdef _MSC_VER1558 if (count)1559 __asm int 3;1560 #endif15611562 return 0;1563}15641565#endif
1758 unmodified lines
modified:tests/stb.dsp+4 added
100 unmodified lines
101SOURCE=.\test_c_compilation.c102# End Source File103# Begin Source File104105SOURCE=.\stretchy_buffer_test.c106# End Source File107# Begin Source File108109SOURCE=.\test_truetype.c110# End Source File111# Begin Source File112
4 unmodified lines
modified:tests/stb.dsw+5 added-2 removed
1 unmodified line
2# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!34###############################################################################56Project: "image_test"=.\image_test\image_test.dsp - Package Owner=<4>6Project: "image_test"=.\image_test.dsp - Package Owner=<4>78Package=<5>9{{{10}}}
3 unmodified lines
14}}}1516###############################################################################1718Project: "make_readme"=..\tools\make_readme\make_readme.dsp - Package Owner=<4>18Project: "make_readme"=..\tools\make_readme.dsp - Package Owner=<4>1920Package=<5>21{{{22}}}
14 unmodified lines
37{{{38 Begin Project Dependency39 Project_Dep_Name stb_cpp40 End Project Dependency41 Begin Project Dependency42 Project_Dep_Name image_test43 End Project Dependency44}}}4546###############################################################################47
24 unmodified lines
added:tests/stretchy_buffer_test.c+1 added
1#include "stretchy_buffer.h"
added:stretchy_buffer.h+148 added
1// stretchy_buffer.h - v0.9 - public domain2// a vector<>-like dynamic array for C3//4// version history:5// 0.9 - rewrite to try to avoid strict-aliasing optimization6// issues, but won't compile as C++7//8// The idea:9//10// This implements an approximation to C++ vector<> for C, in that it11// provides a generic definition for dynamic arrays which you can12// still access in a typesafe way using arr[i] or *(arr+i). However,13// it is simply a convenience wrapper around the common idiom of14// of keeping a set of variables (in a struct or globals) which store15// - pointer to array16// - the length of the "in-use" part of the array17// - the current size of the allocated array18//19// I find it to be single most useful non-built-in-structure when20// programming in C (hash tables a close second), but to be clear21// it lacks many of the capabilities of C++ vector<>: there is no22// range checking, the object address isn't stable (see next section23// for details), the set of methods available is small (although24// the file stb.h has another implementation of stretchy buffers25// called 'stb_arr' which provides more methods, e.g. for insertion26// and deletion).27//28// How to use:29//30// Unlike other stb header file libraries, there is no need to31// define an _IMPLEMENTATION symbol. Every #include creates as32// much implementation is needed.33//34// stretchy_buffer.h does not define any types, so you do not35// need to #include it to before defining data types that are36// stretchy buffers, only in files that *manipulate* stretchy37// buffers.38//39// If you want a stretchy buffer aka dynamic array containing40// objects of TYPE, declare such an array as:41//42// TYPE *myarray = NULL;43//44// (There is no typesafe way to distinguish between stretchy45// buffers and regular arrays/pointers; this is necessary to46// make ordinary array indexing work on these objects.)47//48// Unlike C++ vector<>, the stretchy_buffer has the same49// semantics as an object that you manually malloc and realloc.50// The pointer may relocate every time you add a new object51// to it, so you:52//53// 1. can't take long-term pointers to elements of the array54// 2. have to return the pointer from functions which might expand it55// (either as a return value or by passing it back)56//57// Now you can do the following things with this array:58//59// sb_free(TYPE *a) free the array60// sb_count(TYPE *a) the number of elements in the array61// sb_push(TYPE *a, TYPE v) adds v on the end of the array, a la push_back62// sb_add(TYPE *a, int n) adds n uninitialized elements at end of array & returns pointer to first added63// sb_last(TYPE *a) returns an lvalue of the last item in the array64// a[n] access the nth (counting from 0) element of the array65//66// #define STRETCHY_BUFFER_NO_SHORT_NAMES to only export67// names of the form 'stb_sb_' if you have a name that would68// otherwise collide.69//70// Note that these are all macros and many of them evaluate71// their arguments more than once, so the arguments should72// be side-effect-free.73//74// Note that 'TYPE *a' in sb_push and sb_add must be lvalues75// so that the library can overwrite the existing pointer if76// the object has to be reallocated.77//78// In an out-of-memory condition, the code will try to79// set up a null-pointer or otherwise-invalid-pointer80// exception to happen later. It's possible optimizing81// compilers could detect this write-to-null statically82// and optimize away some of the code, but it should only83// be along the failure path. Nevertheless, for more security84// in the face of such compilers, #define STRETCHY_BUFFER_OUT_OF_MEMORY85// to a statement such as assert(0) or exit(1) or something86// to force a failure when out-of-memory occurs.87//88// How it works:89//90// A long-standing tradition in things like malloc implementations91// is to store extra data before the beginning of the block returned92// to the user. The stretchy buffer implementation here uses the93// same trick; the current-count and current-allocation-size are94// stored before the beginning of the array returned to the user.95// (This means you can't directly free() the pointer, because the96// allocated pointer is different from the type-safe pointer provided97// to the user.)98//99// The details are trivial and implementation is straightforward;100// the main trick is in realizing in the first place that it's101// possible to do this in a generic, type-safe way in C.102103#ifndef STB_STRETCHY_BUFFER_H_INCLUDED104#define STB_STRETCHY_BUFFER_H_INCLUDED105106#ifndef NO_STRETCHY_BUFFER_SHORT_NAMES107#define sb_free stb_sb_free108#define sb_push stb_sb_push109#define sb_count stb_sb_count110#define sb_add stb_sb_add111#define sb_last stb_sb_last112#endif113114#define stb_sb_free(a) ((a) ? free(stb__sbraw(a)),0 : 0)115#define stb_sb_push(a,v) (stb__sbmaybegrow(a,1), (a)[stb__sbn(a)++] = (v))116#define stb_sb_count(a) ((a) ? stb__sbn(a) : 0)117#define stb_sb_add(a,n) (stb__sbmaybegrow(a,n), stb__sbn(a)+=(n), &(a)[stb__sbn(a)-(n)])118#define stb_sb_last(a) ((a)[stb__sbn(a)-1])119120#define stb__sbraw(a) ((int *) (a) - 2)121#define stb__sbm(a) stb__sbraw(a)[0]122#define stb__sbn(a) stb__sbraw(a)[1]123124#define stb__sbneedgrow(a,n) ((a)==0 || stb__sbn(a)+(n) >= stb__sbm(a))125#define stb__sbmaybegrow(a,n) (stb__sbneedgrow(a,(n)) ? stb__sbgrow(a,n) : 0)126#define stb__sbgrow(a,n) ((a) = stb__sbgrowf((a), (n), sizeof(*(a))))127128#include <stdlib.h>129130static void * stb__sbgrowf(void *arr, int increment, int itemsize)131{132 int dbl_cur = arr ? 2*stb__sbm(arr) : 0;133 int min_needed = stb_sb_count(arr) + increment;134 int m = dbl_cur > min_needed ? dbl_cur : min_needed;135 int *p = realloc(arr ? stb__sbraw(arr) : 0, itemsize * m + sizeof(int)*2);136 if (p) {137 if (!arr)138 p[1] = 0;139 p[0] = m;140 return p;141 } else {142 #ifdef STRETCHY_BUFFER_OUT_OF_MEMORY143 STRETCHY_BUFFER_OUT_OF_MEMORY ;144 #endif145 return (void *) (2*sizeof(int)); // try to force a NULL pointer exception later146 }147}148#endif // STB_STRETCHY_BUFFER_H_INCLUDED