diff options
| author | Ray <[email protected]> | 2020-02-04 16:55:24 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2020-02-04 16:55:24 +0100 |
| commit | b5fe41f41a88f3763d02db4f2dfa7e13617e9fc3 (patch) | |
| tree | 71b8e53a39cdc8c9a85bb1a2569d3685070d2591 /src/raudio.c | |
| parent | 3cd9e3896aa6d3cf04ac919f03e51f2b60502906 (diff) | |
| download | raylib-b5fe41f41a88f3763d02db4f2dfa7e13617e9fc3.tar.gz raylib-b5fe41f41a88f3763d02db4f2dfa7e13617e9fc3.zip | |
Review libc dependencies and remove when possible
Just for clarification, no plans to remove libc dependency, just did some code analysis to see how much raylib depend on stardard C library. My conclusions:
- stdlib.h: primary dependency is for malloc() and free()
- stdio.h: primary dependency is for FILE access, maybe it could go through a custom ABI?
- string.h: just around 8 functions required
- math.h: just around 8 functions required
- others: 1-2 functions required for some other headers
Diffstat (limited to 'src/raudio.c')
| -rw-r--r-- | src/raudio.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/raudio.c b/src/raudio.c index d9a5331d..665c0a5c 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -78,8 +78,6 @@ #include "utils.h" // Required for: fopen() Android mapping #endif - - #if defined(_WIN32) // @raysan5: To avoid conflicting windows.h symbols with raylib, so flags are defined // WARNING: Those flags avoid inclusion of some Win32 headers that could be required @@ -163,9 +161,12 @@ typedef struct tagBITMAPINFOHEADER { #undef PlaySound // Win32 API: windows.h > mmsystem.h defines PlaySound macro #include <stdlib.h> // Required for: malloc(), free() -#include <string.h> // Required for: strcmp(), strncmp() #include <stdio.h> // Required for: FILE, fopen(), fclose(), fread() +#if defined(RAUDIO_STANDALONE) + #include <string.h> // Required for: strcmp() [Used in IsFileExtension()] +#endif + #if defined(SUPPORT_FILEFORMAT_OGG) #define STB_VORBIS_IMPLEMENTATION #include "external/stb_vorbis.h" // OGG loading functions @@ -1860,8 +1861,14 @@ static Wave LoadWAV(const char *fileName) fread(&wavRiffHeader, sizeof(WAVRiffHeader), 1, wavFile); // Check for RIFF and WAVE tags - if (strncmp(wavRiffHeader.chunkID, "RIFF", 4) || - strncmp(wavRiffHeader.format, "WAVE", 4)) + if ((wavRiffHeader.chunkID[0] != 'R') || + (wavRiffHeader.chunkID[1] != 'I') || + (wavRiffHeader.chunkID[2] != 'F') || + (wavRiffHeader.chunkID[3] != 'F') || + (wavRiffHeader.format[0] != 'W') || + (wavRiffHeader.format[1] != 'A') || + (wavRiffHeader.format[2] != 'V') || + (wavRiffHeader.format[3] != 'E')) { TRACELOG(LOG_WARNING, "[%s] Invalid RIFF or WAVE Header", fileName); } @@ -2037,7 +2044,7 @@ static Wave LoadOGG(const char *fileName) wave.data = (short *)RL_MALLOC(wave.sampleCount*wave.channels*sizeof(short)); // NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!) - int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels); + //int numSamplesOgg = stb_vorbis_get_samples_short_interleaved(oggFile, info.channels, (short *)wave.data, wave.sampleCount*wave.channels); TRACELOGD("[%s] Samples obtained: %i", fileName, numSamplesOgg); |
