Fossil SCM

Put Th_SubCommand constant tables in constant memory.

jan.nijtmans 2014-01-24 09:54 trunk
Commit dce90fe35eee6c2a0022f298e4a2bdea099b2c8f
2 files changed +2 -2 +3 -3
+2 -2
--- src/th.h
+++ src/th.h
@@ -182,7 +182,7 @@
182182
/*
183183
** Useful functions from th_lang.c.
184184
*/
185185
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg);
186186
187
-typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand;
188
-int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*);
187
+typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand;
188
+int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*);
189189
--- src/th.h
+++ src/th.h
@@ -182,7 +182,7 @@
182 /*
183 ** Useful functions from th_lang.c.
184 */
185 int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg);
186
187 typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand;
188 int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*);
189
--- src/th.h
+++ src/th.h
@@ -182,7 +182,7 @@
182 /*
183 ** Useful functions from th_lang.c.
184 */
185 int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg);
186
187 typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand;
188 int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*);
189
+3 -3
--- src/th_lang.c
+++ src/th_lang.c
@@ -887,11 +887,11 @@
887887
Th_Interp *interp,
888888
void *ctx,
889889
int argc,
890890
const char **argv,
891891
int *argl,
892
- Th_SubCommand *aSub
892
+ const Th_SubCommand *aSub
893893
){
894894
if( argc>1 ){
895895
int i;
896896
for(i=0; aSub[i].zName; i++){
897897
char *zName = (char *)aSub[i].zName;
@@ -924,11 +924,11 @@
924924
void *ctx,
925925
int argc,
926926
const char **argv,
927927
int *argl
928928
){
929
- Th_SubCommand aSub[] = {
929
+ static const Th_SubCommand aSub[] = {
930930
{ "compare", string_compare_command },
931931
{ "first", string_first_command },
932932
{ "is", string_is_command },
933933
{ "last", string_last_command },
934934
{ "length", string_length_command },
@@ -952,11 +952,11 @@
952952
void *ctx,
953953
int argc,
954954
const char **argv,
955955
int *argl
956956
){
957
- Th_SubCommand aSub[] = {
957
+ static const Th_SubCommand aSub[] = {
958958
{ "exists", info_exists_command },
959959
{ 0, 0 }
960960
};
961961
return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
962962
}
963963
--- src/th_lang.c
+++ src/th_lang.c
@@ -887,11 +887,11 @@
887 Th_Interp *interp,
888 void *ctx,
889 int argc,
890 const char **argv,
891 int *argl,
892 Th_SubCommand *aSub
893 ){
894 if( argc>1 ){
895 int i;
896 for(i=0; aSub[i].zName; i++){
897 char *zName = (char *)aSub[i].zName;
@@ -924,11 +924,11 @@
924 void *ctx,
925 int argc,
926 const char **argv,
927 int *argl
928 ){
929 Th_SubCommand aSub[] = {
930 { "compare", string_compare_command },
931 { "first", string_first_command },
932 { "is", string_is_command },
933 { "last", string_last_command },
934 { "length", string_length_command },
@@ -952,11 +952,11 @@
952 void *ctx,
953 int argc,
954 const char **argv,
955 int *argl
956 ){
957 Th_SubCommand aSub[] = {
958 { "exists", info_exists_command },
959 { 0, 0 }
960 };
961 return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
962 }
963
--- src/th_lang.c
+++ src/th_lang.c
@@ -887,11 +887,11 @@
887 Th_Interp *interp,
888 void *ctx,
889 int argc,
890 const char **argv,
891 int *argl,
892 const Th_SubCommand *aSub
893 ){
894 if( argc>1 ){
895 int i;
896 for(i=0; aSub[i].zName; i++){
897 char *zName = (char *)aSub[i].zName;
@@ -924,11 +924,11 @@
924 void *ctx,
925 int argc,
926 const char **argv,
927 int *argl
928 ){
929 static const Th_SubCommand aSub[] = {
930 { "compare", string_compare_command },
931 { "first", string_first_command },
932 { "is", string_is_command },
933 { "last", string_last_command },
934 { "length", string_length_command },
@@ -952,11 +952,11 @@
952 void *ctx,
953 int argc,
954 const char **argv,
955 int *argl
956 ){
957 static const Th_SubCommand aSub[] = {
958 { "exists", info_exists_command },
959 { 0, 0 }
960 };
961 return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
962 }
963

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button