зеркало из https://github.com/github/ruby.git
* gc.c (rb_objspace_free): global_List is allocated with xmalloc.
patched by Sokolov Yura. https://github.com/ruby/ruby/pull/78 * dln_find.c: remove useless replacement of free. * ext/readline/readline.c (readline_attempted_completion_function): strings for readline must allocated with malloc. * process.c (run_exec_dup2): use free; see also r20950. * re.c (onig_new_with_source): use malloc for oniguruma. * vm.c (ruby_vm_destruct): use free for VMs. * vm.c (thread_free): use free for threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a7c9064c8b
Коммит
88b16cebc8
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
Mon Jan 9 04:24:59 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* gc.c (rb_objspace_free): global_List is allocated with xmalloc.
|
||||
patched by Sokolov Yura. https://github.com/ruby/ruby/pull/78
|
||||
|
||||
* dln_find.c: remove useless replacement of free.
|
||||
|
||||
* ext/readline/readline.c (readline_attempted_completion_function):
|
||||
strings for readline must allocated with malloc.
|
||||
|
||||
* process.c (run_exec_dup2): use free; see also r20950.
|
||||
|
||||
* re.c (onig_new_with_source): use malloc for oniguruma.
|
||||
|
||||
* vm.c (ruby_vm_destruct): use free for VMs.
|
||||
|
||||
* vm.c (thread_free): use free for threads.
|
||||
|
||||
Mon Jan 9 04:24:59 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* dln_find.c: remove useless replacement of free.
|
||||
|
||||
* ext/readline/readline.c (filename_completion_proc_call):
|
||||
matches should use xfree.
|
||||
|
||||
* ext/readline/readline.c (username_completion_proc_call): ditto.
|
||||
|
||||
Mon Jan 9 01:12:35 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
|
||||
|
|
|
@ -45,14 +45,6 @@ char *dln_argv0;
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef xmalloc
|
||||
void *xmalloc();
|
||||
void *xcalloc();
|
||||
void *xrealloc();
|
||||
#endif
|
||||
|
||||
#define free(x) xfree(x)
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(_WIN32)
|
||||
#include "missing/file.h"
|
||||
|
|
|
@ -670,12 +670,13 @@ readline_attempted_completion_function(const char *text, int start, int end)
|
|||
if (TYPE(ary) != T_ARRAY)
|
||||
ary = rb_Array(ary);
|
||||
matches = RARRAY_LEN(ary);
|
||||
if (matches == 0)
|
||||
return NULL;
|
||||
result = ALLOC_N(char *, matches + 2);
|
||||
if (matches == NULL) rb_mem_error();
|
||||
result = (char**)malloc((matches + 2)*sizeof(char*));
|
||||
if (result == NULL) rb_raise(rb_eNoMemError, "%s");
|
||||
for (i = 0; i < matches; i++) {
|
||||
temp = rb_obj_as_string(RARRAY_PTR(ary)[i]);
|
||||
result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1);
|
||||
result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1);
|
||||
if (result[i + 1] == NULL) rb_mem_error();
|
||||
strcpy(result[i + 1], RSTRING_PTR(temp));
|
||||
}
|
||||
result[matches + 1] = NULL;
|
||||
|
@ -707,7 +708,8 @@ readline_attempted_completion_function(const char *text, int start, int end)
|
|||
if (low > si) low = si;
|
||||
i++;
|
||||
}
|
||||
result[0] = ALLOC_N(char, low + 1);
|
||||
result[0] = (char*)malloc(low + 1);
|
||||
if (result[0] == NULL) rb_mem_error();
|
||||
strncpy(result[0], result[1], low);
|
||||
result[0][low] = '\0';
|
||||
}
|
||||
|
|
2
gc.c
2
gc.c
|
@ -507,7 +507,7 @@ rb_objspace_free(rb_objspace_t *objspace)
|
|||
struct gc_list *list, *next;
|
||||
for (list = global_List; list; list = next) {
|
||||
next = list->next;
|
||||
free(list);
|
||||
xfree(list);
|
||||
}
|
||||
}
|
||||
if (objspace->heap.free_bitmap) {
|
||||
|
|
|
@ -2151,11 +2151,11 @@ run_exec_dup2(VALUE ary, VALUE save, char *errmsg, size_t errmsg_buflen)
|
|||
}
|
||||
}
|
||||
|
||||
xfree(pairs);
|
||||
free(pairs);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
xfree(pairs);
|
||||
free(pairs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
2
re.c
2
re.c
|
@ -769,7 +769,7 @@ onig_new_with_source(regex_t** reg, const UChar* pattern, const UChar* pattern_e
|
|||
{
|
||||
int r;
|
||||
|
||||
*reg = (regex_t* )xmalloc(sizeof(regex_t));
|
||||
*reg = (regex_t* )malloc(sizeof(regex_t));
|
||||
if (IS_NULL(*reg)) return ONIGERR_MEMORY;
|
||||
|
||||
r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
|
||||
|
|
4
vm.c
4
vm.c
|
@ -1620,7 +1620,7 @@ ruby_vm_destruct(rb_vm_t *vm)
|
|||
#endif
|
||||
ruby_vm_run_at_exit_hooks(vm);
|
||||
rb_vm_gvl_destroy(vm);
|
||||
ruby_xfree(vm);
|
||||
free(vm);
|
||||
ruby_current_vm = 0;
|
||||
}
|
||||
RUBY_FREE_LEAVE("vm");
|
||||
|
@ -1795,7 +1795,7 @@ thread_free(void *ptr)
|
|||
free(th->altstack);
|
||||
}
|
||||
#endif
|
||||
ruby_xfree(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
if (ruby_current_thread == th)
|
||||
ruby_current_thread = NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче