Skip to content

Commit

Permalink
more shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Pizlo committed Mar 1, 2024
1 parent 8e6570f commit 1c6c36c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
3 changes: 1 addition & 2 deletions auth2.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ auth2_setup_methods_lists(Authctxt *authctxt)
if (options.num_auth_methods == 0)
return 0;
debug3_f("checking methods");
authctxt->auth_methods = xcalloc(options.num_auth_methods,
sizeof(*authctxt->auth_methods));
authctxt->auth_methods = zalloc(typeof(*authctxt->auth_methods), options.num_auth_methods);
authctxt->num_auth_methods = 0;
for (i = 0; i < options.num_auth_methods; i++) {
if (auth2_methods_valid(options.auth_methods[i], 1) != 0) {
Expand Down
12 changes: 10 additions & 2 deletions fixalloc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@
# | match |
# "zalloc(typeof(*#{$2}), #{$1})"
#}
contents.gsub!(/xreallocarray\(([^\n]+),\s+([^\n]+),\s+sizeof\(([a-zA-Z0-9_*]+)\)\)/) {
#contents.gsub!(/xreallocarray\(([^\n]+),\s+([^\n]+),\s+sizeof\(([a-zA-Z0-9_*]+)\)\)/) {
# | match |
# "zrealloc(#{$1}, typeof(#{$3}), #{$2})"
#}
#contents.gsub!(/xrecallocarray\(\s*([^\n]+),\s+([^\n]+),\s+([^\n]+),\s+sizeof\(([a-zA-Z0-9_*>-]+)\)\)/) {
# | match |
# "zrealloc(zrestrict(#{$1}, typeof(#{$4}), #{$2}), typeof(#{$4}), #{$3})"
#}
contents.gsub!(/xcalloc\(\s*([^\n]+),\s+sizeof\(([a-zA-Z0-9_*>-]+)\)\)/) {
| match |
"zrealloc(#{$1}, typeof(#{$3}), #{$2})"
"zalloc(typeof(#{$2}), #{$1})"
}
IO::write(filename, contents)
}
35 changes: 8 additions & 27 deletions servconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,7 @@ queue_listen_addr(ServerOptions *options, const char *addr,
{
struct queued_listenaddr *qla;

options->queued_listen_addrs = xrecallocarray(
options->queued_listen_addrs,
options->num_queued_listens, options->num_queued_listens + 1,
sizeof(*options->queued_listen_addrs));
options->queued_listen_addrs = zrealloc(zrestrict(options->queued_listen_addrs, typeof(*options->queued_listen_addrs), options->num_queued_listens), typeof(*options->queued_listen_addrs), options->num_queued_listens + 1);
qla = &options->queued_listen_addrs[options->num_queued_listens++];
qla->addr = xstrdup(addr);
qla->port = port;
Expand Down Expand Up @@ -1919,18 +1916,9 @@ process_server_config_line_depth(ServerOptions *options, char *line,
argv_consume(&ac);
break;
}
options->subsystem_name = xrecallocarray(
options->subsystem_name, options->num_subsystems,
options->num_subsystems + 1,
sizeof(*options->subsystem_name));
options->subsystem_command = xrecallocarray(
options->subsystem_command, options->num_subsystems,
options->num_subsystems + 1,
sizeof(*options->subsystem_command));
options->subsystem_args = xrecallocarray(
options->subsystem_args, options->num_subsystems,
options->num_subsystems + 1,
sizeof(*options->subsystem_args));
options->subsystem_name = zrealloc(zrestrict(options->subsystem_name, typeof(*options->subsystem_name), options->num_subsystems), typeof(*options->subsystem_name), options->num_subsystems + 1);
options->subsystem_command = zrealloc(zrestrict(options->subsystem_command, typeof(*options->subsystem_command), options->num_subsystems), typeof(*options->subsystem_command), options->num_subsystems + 1);
options->subsystem_args = zrealloc(zrestrict(options->subsystem_args, typeof(*options->subsystem_args), options->num_subsystems), typeof(*options->subsystem_args), options->num_subsystems + 1);
options->subsystem_name[options->num_subsystems] = xstrdup(arg);
arg = argv_next(&ac, &av);
if (!arg || *arg == '\0') {
Expand Down Expand Up @@ -2259,8 +2247,7 @@ process_server_config_line_depth(ServerOptions *options, char *line,
if (strcmp(arg, "any") == 0 || strcmp(arg, "none") == 0) {
if (*activep && uvalue == 0) {
*uintptr = 1;
*chararrayptr = xcalloc(1,
sizeof(**chararrayptr));
*chararrayptr = zalloc(typeof(**chararrayptr), 1);
(*chararrayptr)[0] = xstrdup(arg);
}
break;
Expand Down Expand Up @@ -2685,15 +2672,9 @@ servconf_merge_subsystems(ServerOptions *dst, ServerOptions *src)
continue;
}
debug_f("add \"%s\"", src->subsystem_name[i]);
dst->subsystem_name = xrecallocarray(
dst->subsystem_name, dst->num_subsystems,
dst->num_subsystems + 1, sizeof(*dst->subsystem_name));
dst->subsystem_command = xrecallocarray(
dst->subsystem_command, dst->num_subsystems,
dst->num_subsystems + 1, sizeof(*dst->subsystem_command));
dst->subsystem_args = xrecallocarray(
dst->subsystem_args, dst->num_subsystems,
dst->num_subsystems + 1, sizeof(*dst->subsystem_args));
dst->subsystem_name = zrealloc(zrestrict(dst->subsystem_name, typeof(*dst->subsystem_name), dst->num_subsystems), typeof(*dst->subsystem_name), dst->num_subsystems + 1);
dst->subsystem_command = zrealloc(zrestrict(dst->subsystem_command, typeof(*dst->subsystem_command), dst->num_subsystems), typeof(*dst->subsystem_command), dst->num_subsystems + 1);
dst->subsystem_args = zrealloc(zrestrict(dst->subsystem_args, typeof(*dst->subsystem_args), dst->num_subsystems), typeof(*dst->subsystem_args), dst->num_subsystems + 1);
j = dst->num_subsystems++;
dst->subsystem_name[j] = xstrdup(src->subsystem_name[i]);
dst->subsystem_command[j] = xstrdup(src->subsystem_command[i]);
Expand Down

0 comments on commit 1c6c36c

Please sign in to comment.