Skip to content

Commit 0c4b0f0

Browse files
author
grothoff
committed
Hello,
could be possible to change declarations for arrays of strings in the file reason_phrase.c? Currently it is static const char * []. This places all strings into .rodata section and pointers to them into LMA of .text and also into .data in VMA. E.g. for an ARM Cortex M3 (flash + SRAM) compiled with a arm-none-eabi-gcc static const char *one_hundred[] = { "Continue", "Switching Protocols", "Processing" }; Strings "Continue", "Switching Protocols", "Processing" are stored in flash. Also an array with pointers to strings is stored in flash. In addition, this array is copied into SRAM (+16 bytes). If you would change it to "static const char * const one_hundred[]" ... it would occupy only flash. and struct MHD_Reason_Block { ...... const char * const * data; }; I agree, it is not relevant on a PC but on most microcontroller the SRAM is a limiting factor not the rom(flash). Best Martin Velek git-svn-id: https://gnunet.org/svn/libmicrohttpd@25941 140774ce-b5e7-0310-ab8b-a85725594a96
1 parent 242032b commit 0c4b0f0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Wed Jan 30 13:09:30 CET 2013
2+
Adding more 'const' to allow keeping of reason phrases in ROM.
3+
(see mailinglist). -CG/MV
4+
15
Tue Jan 29 21:27:56 CET 2013
26
Make code work with PlibC 0.1.7 (which removed plibc_init_utf8).
37
Only relevant for W32. Fixes #2734. -CG

src/daemon/reason_phrase.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333

3434
static const char *invalid_hundred[] = { NULL };
3535

36-
static const char *one_hundred[] = {
36+
static const char *const one_hundred[] = {
3737
"Continue",
3838
"Switching Protocols",
3939
"Processing"
4040
};
4141

42-
static const char *two_hundred[] = {
42+
static const char *const two_hundred[] = {
4343
"OK",
4444
"Created",
4545
"Accepted",
@@ -50,7 +50,7 @@ static const char *two_hundred[] = {
5050
"Multi Status"
5151
};
5252

53-
static const char *three_hundred[] = {
53+
static const char *const three_hundred[] = {
5454
"Multiple Choices",
5555
"Moved Permanently",
5656
"Moved Temporarily",
@@ -61,7 +61,7 @@ static const char *three_hundred[] = {
6161
"Temporary Redirect"
6262
};
6363

64-
static const char *four_hundred[] = {
64+
static const char *const four_hundred[] = {
6565
"Bad Request",
6666
"Unauthorized",
6767
"Payment Required",
@@ -116,7 +116,7 @@ static const char *four_hundred[] = {
116116
"Unavailable For Legal Reasons"
117117
};
118118

119-
static const char *five_hundred[] = {
119+
static const char *const five_hundred[] = {
120120
"Internal Server Error",
121121
"Not Implemented",
122122
"Bad Gateway",
@@ -134,7 +134,7 @@ static const char *five_hundred[] = {
134134
struct MHD_Reason_Block
135135
{
136136
unsigned int max;
137-
const char **data;
137+
const char *const*data;
138138
};
139139

140140
#define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }

0 commit comments

Comments
 (0)