diff options
author | Volker Grabsch <vog@notjusthosting.com> | 2010-10-04 12:51:46 (GMT) |
---|---|---|
committer | Volker Grabsch <vog@notjusthosting.com> | 2010-10-04 12:51:46 (GMT) |
commit | fb1b630ace75405ef2aa2c4518e3af2778944767 (patch) | |
tree | a5eecc9b8b157f20afc82ffdcab254da8d4d30a0 | |
parent | 40b0701948751c40f2f5f5ed6b1d54143b2ed50c (diff) | |
download | mxe-fb1b630ace75405ef2aa2c4518e3af2778944767.zip mxe-fb1b630ace75405ef2aa2c4518e3af2778944767.tar.gz mxe-fb1b630ace75405ef2aa2c4518e3af2778944767.tar.bz2 |
improved coding style of the examples of packages gd and sdl_sound
-rw-r--r-- | src/gd-test.c | 10 | ||||
-rw-r--r-- | src/sdl_sound-test.c | 78 |
2 files changed, 46 insertions, 42 deletions
diff --git a/src/gd-test.c b/src/gd-test.c index 2d6be72..8d86e3d 100644 --- a/src/gd-test.c +++ b/src/gd-test.c @@ -7,14 +7,18 @@ #include <stdio.h> #include <stdlib.h> -int main() +int main(int argc, char *argv[]) { gdImagePtr im; FILE *fp; - int cor_rad = 400; + int cor_rad; + + (void)argc; + (void)argv; + + cor_rad = 400; im = gdImageCreateTrueColor(400, 400); gdImageFilledRectangle(im, 0, 0, 399, 399, 0x00FFFFFF); - gdImageFilledArc(im, cor_rad, 399 - cor_rad, cor_rad * 2, cor_rad * 2, 90, 180, 0x0, gdPie); fp = fopen("test-gd.png", "wb"); diff --git a/src/sdl_sound-test.c b/src/sdl_sound-test.c index 437e1e1..852b6c8 100644 --- a/src/sdl_sound-test.c +++ b/src/sdl_sound-test.c @@ -6,44 +6,44 @@ #include <stdio.h>
#include <SDL_sound.h>
-int main( int argc, char** argv )
+int main(int argc, char *argv[])
{
- if (argc != 2) {
- fprintf(stderr, "usage: %s <filename>\n", argv[0]);
- return 1;
- }
-
- if (SDL_Init(SDL_INIT_AUDIO) != 0) {
- fprintf(stderr, "Error: %s\n", SDL_GetError());
- return 1;
- }
-
- if (Sound_Init() == 0) {
- fprintf(stderr, "Error: %s\n", Sound_GetError());
- return 1;
- }
-
- SDL_RWops* rw = SDL_RWFromFile(argv[1], "r");
- if (rw == NULL) {
- fprintf(stderr, "Error: %s\n", SDL_GetError());
- return 1;
- }
-
- Sound_AudioInfo wantedFormat;
- wantedFormat.channels = 2;
- wantedFormat.rate = 44100;
- wantedFormat.format = AUDIO_S16LSB;
-
- Sound_Sample* sample = Sound_NewSample(rw, 0, &wantedFormat, 8192);
- if (sample == 0) {
- fprintf(stderr, "Error: %s\n", Sound_GetError());
- return 1;
- }
-
- Sound_DecodeAll(sample);
- printf("Format: %s\n", sample->decoder->description);
- printf("Decoded %d bytes of data.\n", sample->buffer_size);
- Sound_FreeSample(sample);
-
- return 0;
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <filename>\n", argv[0]);
+ return 1;
+ }
+
+ if (SDL_Init(SDL_INIT_AUDIO) != 0) {
+ fprintf(stderr, "Error: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ if (Sound_Init() == 0) {
+ fprintf(stderr, "Error: %s\n", Sound_GetError());
+ return 1;
+ }
+
+ SDL_RWops* rw = SDL_RWFromFile(argv[1], "r");
+ if (rw == NULL) {
+ fprintf(stderr, "Error: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ Sound_AudioInfo wantedFormat;
+ wantedFormat.channels = 2;
+ wantedFormat.rate = 44100;
+ wantedFormat.format = AUDIO_S16LSB;
+
+ Sound_Sample* sample = Sound_NewSample(rw, 0, &wantedFormat, 8192);
+ if (sample == 0) {
+ fprintf(stderr, "Error: %s\n", Sound_GetError());
+ return 1;
+ }
+
+ Sound_DecodeAll(sample);
+ printf("Format: %s\n", sample->decoder->description);
+ printf("Decoded %d bytes of data.\n", sample->buffer_size);
+ Sound_FreeSample(sample);
+
+ return 0;
}
|