diff options
| author | Dan Nicolaescu | 2010-07-04 00:50:25 -0700 |
|---|---|---|
| committer | Dan Nicolaescu | 2010-07-04 00:50:25 -0700 |
| commit | 971de7fb158335fbda39525feb2d7776a26bc030 (patch) | |
| tree | 605333d85f16e35bb06baffcb66ac49f4ec0dce9 /src/ralloc.c | |
| parent | b8463cbfbe2c5183cf40772df2746e58b787ddeb (diff) | |
| download | emacs-971de7fb158335fbda39525feb2d7776a26bc030.tar.gz emacs-971de7fb158335fbda39525feb2d7776a26bc030.zip | |
Convert (most) functions in src to standard C.
* src/alloc.c: Convert function definitions to standard C.
* src/atimer.c:
* src/bidi.c:
* src/bytecode.c:
* src/callint.c:
* src/callproc.c:
* src/casefiddle.c:
* src/casetab.c:
* src/category.c:
* src/ccl.c:
* src/character.c:
* src/charset.c:
* src/chartab.c:
* src/cmds.c:
* src/coding.c:
* src/composite.c:
* src/data.c:
* src/dbusbind.c:
* src/dired.c:
* src/dispnew.c:
* src/doc.c:
* src/doprnt.c:
* src/ecrt0.c:
* src/editfns.c:
* src/fileio.c:
* src/filelock.c:
* src/filemode.c:
* src/fns.c:
* src/font.c:
* src/fontset.c:
* src/frame.c:
* src/fringe.c:
* src/ftfont.c:
* src/ftxfont.c:
* src/gtkutil.c:
* src/indent.c:
* src/insdel.c:
* src/intervals.c:
* src/keymap.c:
* src/lread.c:
* src/macros.c:
* src/marker.c:
* src/md5.c:
* src/menu.c:
* src/minibuf.c:
* src/prefix-args.c:
* src/print.c:
* src/ralloc.c:
* src/regex.c:
* src/region-cache.c:
* src/scroll.c:
* src/search.c:
* src/sound.c:
* src/strftime.c:
* src/syntax.c:
* src/sysdep.c:
* src/termcap.c:
* src/terminal.c:
* src/terminfo.c:
* src/textprop.c:
* src/tparam.c:
* src/undo.c:
* src/unexelf.c:
* src/window.c:
* src/xfaces.c:
* src/xfns.c:
* src/xfont.c:
* src/xftfont.c:
* src/xgselect.c:
* src/xmenu.c:
* src/xrdb.c:
* src/xselect.c:
* src/xsettings.c:
* src/xsmfns.c:
* src/xterm.c: Likewise.
Diffstat (limited to 'src/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index 7ccbdc7daf7..dd68e7c8afc 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -40,11 +40,11 @@ typedef size_t SIZE; | |||
| 40 | /* Declared in dispnew.c, this version doesn't screw up if regions | 40 | /* Declared in dispnew.c, this version doesn't screw up if regions |
| 41 | overlap. */ | 41 | overlap. */ |
| 42 | 42 | ||
| 43 | extern void safe_bcopy (); | 43 | extern void safe_bcopy (const char *, char *, int); |
| 44 | 44 | ||
| 45 | #ifdef DOUG_LEA_MALLOC | 45 | #ifdef DOUG_LEA_MALLOC |
| 46 | #define M_TOP_PAD -2 | 46 | #define M_TOP_PAD -2 |
| 47 | extern int mallopt (); | 47 | extern int mallopt (int, int); |
| 48 | #else /* not DOUG_LEA_MALLOC */ | 48 | #else /* not DOUG_LEA_MALLOC */ |
| 49 | #ifndef SYSTEM_MALLOC | 49 | #ifndef SYSTEM_MALLOC |
| 50 | extern size_t __malloc_extra_blocks; | 50 | extern size_t __malloc_extra_blocks; |
| @@ -81,7 +81,7 @@ typedef void *POINTER; | |||
| 81 | 81 | ||
| 82 | static int r_alloc_initialized = 0; | 82 | static int r_alloc_initialized = 0; |
| 83 | 83 | ||
| 84 | static void r_alloc_init (); | 84 | static void r_alloc_init (void); |
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | /* Declarations for working with the malloc, ralloc, and system breaks. */ | 87 | /* Declarations for working with the malloc, ralloc, and system breaks. */ |
| @@ -210,8 +210,7 @@ static int r_alloc_freeze_level; | |||
| 210 | /* Find the heap that ADDRESS falls within. */ | 210 | /* Find the heap that ADDRESS falls within. */ |
| 211 | 211 | ||
| 212 | static heap_ptr | 212 | static heap_ptr |
| 213 | find_heap (address) | 213 | find_heap (POINTER address) |
| 214 | POINTER address; | ||
| 215 | { | 214 | { |
| 216 | heap_ptr heap; | 215 | heap_ptr heap; |
| 217 | 216 | ||
| @@ -243,9 +242,7 @@ find_heap (address) | |||
| 243 | allocate the memory. */ | 242 | allocate the memory. */ |
| 244 | 243 | ||
| 245 | static POINTER | 244 | static POINTER |
| 246 | obtain (address, size) | 245 | obtain (POINTER address, SIZE size) |
| 247 | POINTER address; | ||
| 248 | SIZE size; | ||
| 249 | { | 246 | { |
| 250 | heap_ptr heap; | 247 | heap_ptr heap; |
| 251 | SIZE already_available; | 248 | SIZE already_available; |
| @@ -326,7 +323,7 @@ obtain (address, size) | |||
| 326 | it can also eliminate the last heap entirely. */ | 323 | it can also eliminate the last heap entirely. */ |
| 327 | 324 | ||
| 328 | static void | 325 | static void |
| 329 | relinquish () | 326 | relinquish (void) |
| 330 | { | 327 | { |
| 331 | register heap_ptr h; | 328 | register heap_ptr h; |
| 332 | long excess = 0; | 329 | long excess = 0; |
| @@ -385,7 +382,7 @@ relinquish () | |||
| 385 | above where malloc gets space. */ | 382 | above where malloc gets space. */ |
| 386 | 383 | ||
| 387 | long | 384 | long |
| 388 | r_alloc_size_in_use () | 385 | r_alloc_size_in_use (void) |
| 389 | { | 386 | { |
| 390 | return (char *) break_value - (char *) virtual_break_value; | 387 | return (char *) break_value - (char *) virtual_break_value; |
| 391 | } | 388 | } |
| @@ -396,8 +393,7 @@ r_alloc_size_in_use () | |||
| 396 | to that block. */ | 393 | to that block. */ |
| 397 | 394 | ||
| 398 | static bloc_ptr | 395 | static bloc_ptr |
| 399 | find_bloc (ptr) | 396 | find_bloc (POINTER *ptr) |
| 400 | POINTER *ptr; | ||
| 401 | { | 397 | { |
| 402 | register bloc_ptr p = first_bloc; | 398 | register bloc_ptr p = first_bloc; |
| 403 | 399 | ||
| @@ -422,8 +418,7 @@ find_bloc (ptr) | |||
| 422 | memory for the new block. */ | 418 | memory for the new block. */ |
| 423 | 419 | ||
| 424 | static bloc_ptr | 420 | static bloc_ptr |
| 425 | get_bloc (size) | 421 | get_bloc (SIZE size) |
| 426 | SIZE size; | ||
| 427 | { | 422 | { |
| 428 | register bloc_ptr new_bloc; | 423 | register bloc_ptr new_bloc; |
| 429 | register heap_ptr heap; | 424 | register heap_ptr heap; |
| @@ -478,10 +473,7 @@ get_bloc (size) | |||
| 478 | Do not touch the contents of blocs or break_value. */ | 473 | Do not touch the contents of blocs or break_value. */ |
| 479 | 474 | ||
| 480 | static int | 475 | static int |
| 481 | relocate_blocs (bloc, heap, address) | 476 | relocate_blocs (bloc_ptr bloc, heap_ptr heap, POINTER address) |
| 482 | bloc_ptr bloc; | ||
| 483 | heap_ptr heap; | ||
| 484 | POINTER address; | ||
| 485 | { | 477 | { |
| 486 | register bloc_ptr b = bloc; | 478 | register bloc_ptr b = bloc; |
| 487 | 479 | ||
| @@ -541,8 +533,7 @@ relocate_blocs (bloc, heap, address) | |||
| 541 | before that of BEFORE. */ | 533 | before that of BEFORE. */ |
| 542 | 534 | ||
| 543 | static void | 535 | static void |
| 544 | reorder_bloc (bloc, before) | 536 | reorder_bloc (bloc_ptr bloc, bloc_ptr before) |
| 545 | bloc_ptr bloc, before; | ||
| 546 | { | 537 | { |
| 547 | bloc_ptr prev, next; | 538 | bloc_ptr prev, next; |
| 548 | 539 | ||
| @@ -570,9 +561,7 @@ reorder_bloc (bloc, before) | |||
| 570 | with heap HEAP and bloc BLOC. */ | 561 | with heap HEAP and bloc BLOC. */ |
| 571 | 562 | ||
| 572 | static void | 563 | static void |
| 573 | update_heap_bloc_correspondence (bloc, heap) | 564 | update_heap_bloc_correspondence (bloc_ptr bloc, heap_ptr heap) |
| 574 | bloc_ptr bloc; | ||
| 575 | heap_ptr heap; | ||
| 576 | { | 565 | { |
| 577 | register bloc_ptr b; | 566 | register bloc_ptr b; |
| 578 | 567 | ||
| @@ -634,9 +623,7 @@ update_heap_bloc_correspondence (bloc, heap) | |||
| 634 | that come after BLOC in memory. */ | 623 | that come after BLOC in memory. */ |
| 635 | 624 | ||
| 636 | static int | 625 | static int |
| 637 | resize_bloc (bloc, size) | 626 | resize_bloc (bloc_ptr bloc, SIZE size) |
| 638 | bloc_ptr bloc; | ||
| 639 | SIZE size; | ||
| 640 | { | 627 | { |
| 641 | register bloc_ptr b; | 628 | register bloc_ptr b; |
| 642 | heap_ptr heap; | 629 | heap_ptr heap; |
| @@ -733,8 +720,7 @@ resize_bloc (bloc, size) | |||
| 733 | This may return space to the system. */ | 720 | This may return space to the system. */ |
| 734 | 721 | ||
| 735 | static void | 722 | static void |
| 736 | free_bloc (bloc) | 723 | free_bloc (bloc_ptr bloc) |
| 737 | bloc_ptr bloc; | ||
| 738 | { | 724 | { |
| 739 | heap_ptr heap = bloc->heap; | 725 | heap_ptr heap = bloc->heap; |
| 740 | 726 | ||
| @@ -800,8 +786,7 @@ free_bloc (bloc) | |||
| 800 | GNU malloc package. */ | 786 | GNU malloc package. */ |
| 801 | 787 | ||
| 802 | POINTER | 788 | POINTER |
| 803 | r_alloc_sbrk (size) | 789 | r_alloc_sbrk (long int size) |
| 804 | long size; | ||
| 805 | { | 790 | { |
| 806 | register bloc_ptr b; | 791 | register bloc_ptr b; |
| 807 | POINTER address; | 792 | POINTER address; |
| @@ -952,9 +937,7 @@ r_alloc_sbrk (size) | |||
| 952 | return zero. */ | 937 | return zero. */ |
| 953 | 938 | ||
| 954 | POINTER | 939 | POINTER |
| 955 | r_alloc (ptr, size) | 940 | r_alloc (POINTER *ptr, SIZE size) |
| 956 | POINTER *ptr; | ||
| 957 | SIZE size; | ||
| 958 | { | 941 | { |
| 959 | register bloc_ptr new_bloc; | 942 | register bloc_ptr new_bloc; |
| 960 | 943 | ||
| @@ -977,8 +960,7 @@ r_alloc (ptr, size) | |||
| 977 | Store 0 in *PTR to show there's no block allocated. */ | 960 | Store 0 in *PTR to show there's no block allocated. */ |
| 978 | 961 | ||
| 979 | void | 962 | void |
| 980 | r_alloc_free (ptr) | 963 | r_alloc_free (register POINTER *ptr) |
| 981 | register POINTER *ptr; | ||
| 982 | { | 964 | { |
| 983 | register bloc_ptr dead_bloc; | 965 | register bloc_ptr dead_bloc; |
| 984 | 966 | ||
| @@ -1012,9 +994,7 @@ r_alloc_free (ptr) | |||
| 1012 | return zero. */ | 994 | return zero. */ |
| 1013 | 995 | ||
| 1014 | POINTER | 996 | POINTER |
| 1015 | r_re_alloc (ptr, size) | 997 | r_re_alloc (POINTER *ptr, SIZE size) |
| 1016 | POINTER *ptr; | ||
| 1017 | SIZE size; | ||
| 1018 | { | 998 | { |
| 1019 | register bloc_ptr bloc; | 999 | register bloc_ptr bloc; |
| 1020 | 1000 | ||
| @@ -1075,8 +1055,7 @@ r_re_alloc (ptr, size) | |||
| 1075 | malloc must return a null pointer. */ | 1055 | malloc must return a null pointer. */ |
| 1076 | 1056 | ||
| 1077 | void | 1057 | void |
| 1078 | r_alloc_freeze (size) | 1058 | r_alloc_freeze (long int size) |
| 1079 | long size; | ||
| 1080 | { | 1059 | { |
| 1081 | if (! r_alloc_initialized) | 1060 | if (! r_alloc_initialized) |
| 1082 | r_alloc_init (); | 1061 | r_alloc_init (); |
| @@ -1093,7 +1072,7 @@ r_alloc_freeze (size) | |||
| 1093 | } | 1072 | } |
| 1094 | 1073 | ||
| 1095 | void | 1074 | void |
| 1096 | r_alloc_thaw () | 1075 | r_alloc_thaw (void) |
| 1097 | { | 1076 | { |
| 1098 | 1077 | ||
| 1099 | if (! r_alloc_initialized) | 1078 | if (! r_alloc_initialized) |
| @@ -1122,7 +1101,7 @@ r_alloc_thaw () | |||
| 1122 | /* Reinitialize the morecore hook variables after restarting a dumped | 1101 | /* Reinitialize the morecore hook variables after restarting a dumped |
| 1123 | Emacs. This is needed when using Doug Lea's malloc from GNU libc. */ | 1102 | Emacs. This is needed when using Doug Lea's malloc from GNU libc. */ |
| 1124 | void | 1103 | void |
| 1125 | r_alloc_reinit () | 1104 | r_alloc_reinit (void) |
| 1126 | { | 1105 | { |
| 1127 | /* Only do this if the hook has been reset, so that we don't get an | 1106 | /* Only do this if the hook has been reset, so that we don't get an |
| 1128 | infinite loop, in case Emacs was linked statically. */ | 1107 | infinite loop, in case Emacs was linked statically. */ |
| @@ -1235,8 +1214,7 @@ r_alloc_check () | |||
| 1235 | is checked to ensure that memory corruption does not occur due to | 1214 | is checked to ensure that memory corruption does not occur due to |
| 1236 | misuse. */ | 1215 | misuse. */ |
| 1237 | void | 1216 | void |
| 1238 | r_alloc_reset_variable (old, new) | 1217 | r_alloc_reset_variable (POINTER *old, POINTER *new) |
| 1239 | POINTER *old, *new; | ||
| 1240 | { | 1218 | { |
| 1241 | bloc_ptr bloc = first_bloc; | 1219 | bloc_ptr bloc = first_bloc; |
| 1242 | 1220 | ||
| @@ -1266,7 +1244,7 @@ r_alloc_reset_variable (old, new) | |||
| 1266 | /* Initialize various things for memory allocation. */ | 1244 | /* Initialize various things for memory allocation. */ |
| 1267 | 1245 | ||
| 1268 | static void | 1246 | static void |
| 1269 | r_alloc_init () | 1247 | r_alloc_init (void) |
| 1270 | { | 1248 | { |
| 1271 | if (r_alloc_initialized) | 1249 | if (r_alloc_initialized) |
| 1272 | return; | 1250 | return; |