Changeset 609 for branches/GNU/src/binutils/intl/loadmsgcat.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/intl/loadmsgcat.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 /* Load needed message catalogs 2 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.1 /* Load needed message catalogs. 2 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 45 45 because some ISO C functions will require linking with this object 46 46 file and the name space must not be polluted. */ 47 # define fstat __fstat48 47 # define open __open 49 48 # define close __close … … 62 61 message catalog do nothing. */ 63 62 void 63 internal_function 64 64 _nl_load_domain (domain_file) 65 65 struct loaded_l10nfile *domain_file; 66 66 { 67 67 int fd; 68 size_t size; 68 69 struct stat st; 69 70 struct mo_file_header *data = (struct mo_file_header *) -1; … … 91 92 /* We must know about the size of the file. */ 92 93 if (fstat (fd, &st) != 0 93 && st.st_size < (off_t) sizeof (struct mo_file_header)) 94 || (size = (size_t) st.st_size) != st.st_size 95 || size < sizeof (struct mo_file_header)) 94 96 { 95 97 /* Something went wrong. */ … … 102 104 /* Now we are ready to load the file. If mmap() is available we try 103 105 this first. If not available or it failed we try to load it. */ 104 data = (struct mo_file_header *) mmap (NULL, s t.st_size, PROT_READ,106 data = (struct mo_file_header *) mmap (NULL, size, PROT_READ, 105 107 MAP_PRIVATE, fd, 0); 106 108 … … 117 119 if (data == (struct mo_file_header *) -1) 118 120 { 119 off_t to_read;121 size_t to_read; 120 122 char *read_ptr; 121 123 122 data = (struct mo_file_header *) malloc (s t.st_size);124 data = (struct mo_file_header *) malloc (size); 123 125 if (data == NULL) 124 126 return; 125 127 126 to_read = s t.st_size;128 to_read = size; 127 129 read_ptr = (char *) data; 128 130 do … … 151 153 || defined _LIBC 152 154 if (use_mmap) 153 munmap ((caddr_t) data, s t.st_size);155 munmap ((caddr_t) data, size); 154 156 else 155 157 #endif … … 165 167 domain = (struct loaded_domain *) domain_file->data; 166 168 domain->data = (char *) data; 169 #if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ 170 || defined _LIBC 171 domain->use_mmap = use_mmap; 172 #endif 173 domain->mmap_size = size; 167 174 domain->must_swap = data->magic != _MAGIC; 168 175 … … 185 192 || defined _LIBC 186 193 if (use_mmap) 187 munmap ((caddr_t) data, s t.st_size);194 munmap ((caddr_t) data, size); 188 195 else 189 196 #endif … … 198 205 ++_nl_msg_cat_cntr; 199 206 } 207 208 209 #ifdef _LIBC 210 void 211 internal_function 212 _nl_unload_domain (domain) 213 struct loaded_domain *domain; 214 { 215 if (domain->use_mmap) 216 munmap ((caddr_t) domain->data, domain->mmap_size); 217 else 218 free ((void *) domain->data); 219 220 free (domain); 221 } 222 #endif -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.