diff options
| author | Gerd Moellmann | 2000-08-02 20:15:51 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-08-02 20:15:51 +0000 |
| commit | 675d51309049637ae99c912cbc1a0db0dfb5d543 (patch) | |
| tree | 0eab8228c0dc35146eca1290e59d3c09a67fd421 /src/alloc.c | |
| parent | f66aa8f2c1404aa967ecab912db05dfd3ffca5d9 (diff) | |
| download | emacs-675d51309049637ae99c912cbc1a0db0dfb5d543.tar.gz emacs-675d51309049637ae99c912cbc1a0db0dfb5d543.zip | |
(lisp_malloc, lisp_free): Use size_t and POINTER_TYPE.
(xrealloc, xmalloc): Use size_t.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c index 38ae9d34924..b7c61b4bd07 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -282,7 +282,7 @@ enum mem_type | |||
| 282 | Lisp_Object Vdead; | 282 | Lisp_Object Vdead; |
| 283 | 283 | ||
| 284 | struct mem_node; | 284 | struct mem_node; |
| 285 | static void *lisp_malloc P_ ((int, enum mem_type)); | 285 | static void *lisp_malloc P_ ((size_t, enum mem_type)); |
| 286 | static void mark_stack P_ ((void)); | 286 | static void mark_stack P_ ((void)); |
| 287 | static void init_stack P_ ((Lisp_Object *)); | 287 | static void init_stack P_ ((Lisp_Object *)); |
| 288 | static int live_vector_p P_ ((struct mem_node *, void *)); | 288 | static int live_vector_p P_ ((struct mem_node *, void *)); |
| @@ -410,7 +410,7 @@ buffer_memory_full () | |||
| 410 | 410 | ||
| 411 | POINTER_TYPE * | 411 | POINTER_TYPE * |
| 412 | xmalloc (size) | 412 | xmalloc (size) |
| 413 | int size; | 413 | size_t size; |
| 414 | { | 414 | { |
| 415 | register POINTER_TYPE *val; | 415 | register POINTER_TYPE *val; |
| 416 | 416 | ||
| @@ -429,7 +429,7 @@ xmalloc (size) | |||
| 429 | POINTER_TYPE * | 429 | POINTER_TYPE * |
| 430 | xrealloc (block, size) | 430 | xrealloc (block, size) |
| 431 | POINTER_TYPE *block; | 431 | POINTER_TYPE *block; |
| 432 | int size; | 432 | size_t size; |
| 433 | { | 433 | { |
| 434 | register POINTER_TYPE *val; | 434 | register POINTER_TYPE *val; |
| 435 | 435 | ||
| @@ -465,7 +465,7 @@ char * | |||
| 465 | xstrdup (s) | 465 | xstrdup (s) |
| 466 | char *s; | 466 | char *s; |
| 467 | { | 467 | { |
| 468 | int len = strlen (s) + 1; | 468 | size_t len = strlen (s) + 1; |
| 469 | char *p = (char *) xmalloc (len); | 469 | char *p = (char *) xmalloc (len); |
| 470 | bcopy (s, p, len); | 470 | bcopy (s, p, len); |
| 471 | return p; | 471 | return p; |
| @@ -476,9 +476,9 @@ xstrdup (s) | |||
| 476 | number of bytes to allocate, TYPE describes the intended use of the | 476 | number of bytes to allocate, TYPE describes the intended use of the |
| 477 | allcated memory block (for strings, for conses, ...). */ | 477 | allcated memory block (for strings, for conses, ...). */ |
| 478 | 478 | ||
| 479 | static void * | 479 | static POINTER_TYPE * |
| 480 | lisp_malloc (nbytes, type) | 480 | lisp_malloc (nbytes, type) |
| 481 | int nbytes; | 481 | size_t nbytes; |
| 482 | enum mem_type type; | 482 | enum mem_type type; |
| 483 | { | 483 | { |
| 484 | register void *val; | 484 | register void *val; |
| @@ -514,7 +514,7 @@ allocate_buffer () | |||
| 514 | 514 | ||
| 515 | void | 515 | void |
| 516 | lisp_free (block) | 516 | lisp_free (block) |
| 517 | long *block; | 517 | POINTER_TYPE *block; |
| 518 | { | 518 | { |
| 519 | BLOCK_INPUT; | 519 | BLOCK_INPUT; |
| 520 | free (block); | 520 | free (block); |
| @@ -543,6 +543,8 @@ extern void * (*__realloc_hook) (); | |||
| 543 | static void * (*old_realloc_hook) (); | 543 | static void * (*old_realloc_hook) (); |
| 544 | extern void (*__free_hook) (); | 544 | extern void (*__free_hook) (); |
| 545 | static void (*old_free_hook) (); | 545 | static void (*old_free_hook) (); |
| 546 | static void *emacs_blocked_malloc P_ ((size_t)); | ||
| 547 | static void *emacs_blocked_realloc P_ ((void *, size_t)); | ||
| 546 | 548 | ||
| 547 | /* This function is used as the hook for free to call. */ | 549 | /* This function is used as the hook for free to call. */ |
| 548 | 550 | ||
| @@ -563,7 +565,7 @@ emacs_blocked_free (ptr) | |||
| 563 | is substantially larger than the block size malloc uses. */ | 565 | is substantially larger than the block size malloc uses. */ |
| 564 | && (bytes_used_when_full | 566 | && (bytes_used_when_full |
| 565 | > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY)) | 567 | > BYTES_USED + max (malloc_hysteresis, 4) * SPARE_MEMORY)) |
| 566 | spare_memory = (char *) malloc (SPARE_MEMORY); | 568 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); |
| 567 | 569 | ||
| 568 | __free_hook = emacs_blocked_free; | 570 | __free_hook = emacs_blocked_free; |
| 569 | UNBLOCK_INPUT; | 571 | UNBLOCK_INPUT; |
| @@ -580,7 +582,7 @@ void | |||
| 580 | refill_memory_reserve () | 582 | refill_memory_reserve () |
| 581 | { | 583 | { |
| 582 | if (spare_memory == 0) | 584 | if (spare_memory == 0) |
| 583 | spare_memory = (char *) malloc (SPARE_MEMORY); | 585 | spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); |
| 584 | } | 586 | } |
| 585 | 587 | ||
| 586 | 588 | ||
| @@ -588,7 +590,7 @@ refill_memory_reserve () | |||
| 588 | 590 | ||
| 589 | static void * | 591 | static void * |
| 590 | emacs_blocked_malloc (size) | 592 | emacs_blocked_malloc (size) |
| 591 | unsigned size; | 593 | size_t size; |
| 592 | { | 594 | { |
| 593 | void *value; | 595 | void *value; |
| 594 | 596 | ||
| @@ -612,7 +614,7 @@ emacs_blocked_malloc (size) | |||
| 612 | static void * | 614 | static void * |
| 613 | emacs_blocked_realloc (ptr, size) | 615 | emacs_blocked_realloc (ptr, size) |
| 614 | void *ptr; | 616 | void *ptr; |
| 615 | unsigned size; | 617 | size_t size; |
| 616 | { | 618 | { |
| 617 | void *value; | 619 | void *value; |
| 618 | 620 | ||
| @@ -1039,7 +1041,7 @@ allocate_string_data (s, nchars, nbytes) | |||
| 1039 | 1041 | ||
| 1040 | if (nbytes > LARGE_STRING_BYTES) | 1042 | if (nbytes > LARGE_STRING_BYTES) |
| 1041 | { | 1043 | { |
| 1042 | int size = sizeof *b - sizeof (struct sdata) + needed; | 1044 | size_t size = sizeof *b - sizeof (struct sdata) + needed; |
| 1043 | 1045 | ||
| 1044 | #ifdef DOUG_LEA_MALLOC | 1046 | #ifdef DOUG_LEA_MALLOC |
| 1045 | /* Prevent mmap'ing the chunk (which is potentially very large). */ | 1047 | /* Prevent mmap'ing the chunk (which is potentially very large). */ |
| @@ -1827,7 +1829,7 @@ allocate_vectorlike (len) | |||
| 1827 | EMACS_INT len; | 1829 | EMACS_INT len; |
| 1828 | { | 1830 | { |
| 1829 | struct Lisp_Vector *p; | 1831 | struct Lisp_Vector *p; |
| 1830 | int nbytes; | 1832 | size_t nbytes; |
| 1831 | 1833 | ||
| 1832 | #ifdef DOUG_LEA_MALLOC | 1834 | #ifdef DOUG_LEA_MALLOC |
| 1833 | /* Prevent mmap'ing the chunk (which is potentially very large).. */ | 1835 | /* Prevent mmap'ing the chunk (which is potentially very large).. */ |
| @@ -3262,7 +3264,7 @@ make_pure_float (num) | |||
| 3262 | this, and I suspect that floats are rare enough that it's no | 3264 | this, and I suspect that floats are rare enough that it's no |
| 3263 | tragedy for those that do. */ | 3265 | tragedy for those that do. */ |
| 3264 | { | 3266 | { |
| 3265 | int alignment; | 3267 | size_t alignment; |
| 3266 | char *p = PUREBEG + pureptr; | 3268 | char *p = PUREBEG + pureptr; |
| 3267 | 3269 | ||
| 3268 | #ifdef __GNUC__ | 3270 | #ifdef __GNUC__ |