summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/malloc.c
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2024-07-22 21:43:25 -0400
committerFranklin Wei <franklin@rockbox.org>2024-07-22 21:44:08 -0400
commit09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c (patch)
tree182bd4efb2dc8ca4fcb369d8cccab0c0f290d054 /apps/plugins/puzzles/src/malloc.c
parentc72030f98c953a82ed6f5c7132ad000c3d5f4a16 (diff)
downloadrockbox-09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c.tar.gz
rockbox-09aa8de52cb962f1ceebfb1fd44f2c54a924fc5c.zip
puzzles: resync with upstream
This brings the puzzles source in sync with Simon's branch, commit fd304c5 (from March 2024), with some added Rockbox-specific compatibility changes: https://www.franklinwei.com/git/puzzles/commit/?h=rockbox-devel&id=516830d9d76bdfe64fe5ccf2a9b59c33f5c7c078 There are quite a lot of backend changes, including a new "Mosaic" puzzle. In addition, some new frontend changes were necessary: - New "Preferences" menu to access the user preferences system. - Enabled spacebar input for several games. Change-Id: I94c7df674089c92f32d5f07025f6a1059068af1e
Diffstat (limited to 'apps/plugins/puzzles/src/malloc.c')
-rw-r--r--apps/plugins/puzzles/src/malloc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/plugins/puzzles/src/malloc.c b/apps/plugins/puzzles/src/malloc.c
index a7fa7c5adc..39bcfac25b 100644
--- a/apps/plugins/puzzles/src/malloc.c
+++ b/apps/plugins/puzzles/src/malloc.c
@@ -2,16 +2,23 @@
2 * malloc.c: safe wrappers around malloc, realloc, free, strdup 2 * malloc.c: safe wrappers around malloc, realloc, free, strdup
3 */ 3 */
4 4
5#ifndef NO_STDINT_H
6#include <stdint.h>
7#endif
5#include <stdlib.h> 8#include <stdlib.h>
6#include <string.h> 9#include <string.h>
7#include "puzzles.h" 10#include "puzzles.h"
8 11
9/* 12/*
10 * smalloc should guarantee to return a useful pointer - Halibut 13 * smalloc should guarantee to return a useful pointer - we
11 * can do nothing except die when it's out of memory anyway. 14 * can do nothing except die when it's out of memory anyway.
12 */ 15 */
13void *smalloc(size_t size) { 16void *smalloc(size_t size) {
14 void *p; 17 void *p;
18#ifdef PTRDIFF_MAX
19 if (size > PTRDIFF_MAX)
20 fatal("allocation too large");
21#endif
15 p = malloc(size); 22 p = malloc(size);
16 if (!p) 23 if (!p)
17 fatal("out of memory"); 24 fatal("out of memory");
@@ -32,6 +39,10 @@ void sfree(void *p) {
32 */ 39 */
33void *srealloc(void *p, size_t size) { 40void *srealloc(void *p, size_t size) {
34 void *q; 41 void *q;
42#ifdef PTRDIFF_MAX
43 if (size > PTRDIFF_MAX)
44 fatal("allocation too large");
45#endif
35 if (p) { 46 if (p) {
36 q = realloc(p, size); 47 q = realloc(p, size);
37 } else { 48 } else {