[patch]: makes some arrays const to be shared between processes
Andrew V. Samoilov
kai at cmail.ru
Fri Oct 19 07:16:04 GMT 2001
Hi!
This patch makes some arrays const. So these arrays go to text/rodata
segment and are shared between all of the processes which use shared
library with these arrays.
Regards,
Andrew V. Samoilov.
P.S. Please cc your answer to kai at cmail.ru,
I don't subscribed to this list.
ChangeLog:
* cliconnect.c (prots): Make const.
* clierror.c (rap_errmap): Likewise.
* nmblib.c (nmb_header_opcode_names): Likewise.
(lookup_opcode_name): Make opcode_namep const. Eliminate i.
* nterr.c (nt_err_code_struct): Typedef const.
* smberr.c (err_code_struct): Make const.
(err_classes): Likewise.
diff -upr samba-2.2.2-orig/source/libsmb/cliconnect.c samba-2.2.2/source/libsmb/cliconnect.c
--- samba-2.2.2-orig/source/libsmb/cliconnect.c Fri Jul 6 05:01:37 2001
+++ samba-2.2.2/source/libsmb/cliconnect.c Fri Oct 19 16:57:58 2001
@@ -24,7 +24,7 @@
#include "includes.h"
-static struct {
+static const struct {
int prot;
char *name;
}
diff -upr samba-2.2.2-orig/source/libsmb/clierror.c samba-2.2.2/source/libsmb/clierror.c
--- samba-2.2.2-orig/source/libsmb/clierror.c Sun Oct 14 00:09:27 2001
+++ samba-2.2.2/source/libsmb/clierror.c Fri Oct 19 16:57:58 2001
@@ -31,7 +31,7 @@ extern int DEBUGLEVEL;
RAP error codes - a small start but will be extended.
*******************************************************/
-static struct
+static const struct
{
int err;
char *message;
diff -upr samba-2.2.2-orig/source/libsmb/nmblib.c samba-2.2.2/source/libsmb/nmblib.c
--- samba-2.2.2-orig/source/libsmb/nmblib.c Fri Apr 13 07:09:37 2001
+++ samba-2.2.2/source/libsmb/nmblib.c Fri Oct 19 17:03:11 2001
@@ -27,7 +27,7 @@ extern int DEBUGLEVEL;
int num_good_sends = 0;
int num_good_receives = 0;
-static struct opcode_names {
+static const struct opcode_names {
char *nmb_opcode_name;
int opcode;
} nmb_header_opcode_names[] = {
@@ -46,14 +46,13 @@ static struct opcode_names {
****************************************************************************/
static char *lookup_opcode_name( int opcode )
{
- struct opcode_names *op_namep;
- int i;
+ const struct opcode_names *op_namep = &nmb_header_opcode_names[0];
- for(i = 0; nmb_header_opcode_names[i].nmb_opcode_name != 0; i++) {
- op_namep = &nmb_header_opcode_names[i];
+ do {
if(opcode == op_namep->opcode)
return op_namep->nmb_opcode_name;
- }
+ op_namep++;
+ } while (op_namep->nmb_opcode_name);
return "<unknown opcode>";
}
diff -upr samba-2.2.2-orig/source/libsmb/nterr.c samba-2.2.2/source/libsmb/nterr.c
--- samba-2.2.2-orig/source/libsmb/nterr.c Mon Jan 8 22:37:45 2001
+++ samba-2.2.2/source/libsmb/nterr.c Fri Oct 19 16:57:58 2001
@@ -2,7 +2,7 @@
#include "includes.h"
-typedef struct
+typedef const struct
{
char *nt_errstr;
uint32 nt_errcode;
diff -upr samba-2.2.2-orig/source/libsmb/smberr.c samba-2.2.2/source/libsmb/smberr.c
--- samba-2.2.2-orig/source/libsmb/smberr.c Sun Oct 14 00:09:27 2001
+++ samba-2.2.2/source/libsmb/smberr.c Fri Oct 19 17:14:25 2001
@@ -27,7 +27,7 @@ extern int DEBUGLEVEL;
/* error code stuff - put together by Merik Karman
merik at blackadder.dsh.oz.au */
-typedef struct
+typedef const struct
{
char *name;
int code;
@@ -127,7 +127,7 @@ err_code_struct hard_msgs[] = {
{NULL,-1,NULL}};
-struct
+const struct
{
int code;
char *class;
More information about the samba-technical
mailing list