diff --git a/src/job.cpp b/src/job.cpp index d2b4d4918..a773a5d52 100644 --- a/src/job.cpp +++ b/src/job.cpp @@ -44,6 +44,10 @@ #include #include #include +#ifdef __APPLE__ +#include +#include +#endif // How many times to SIGTERM a process before SIGKILL #define TERM_ATTEMPTS 6 @@ -320,9 +324,22 @@ JobTable::JobTable(Database *db, double percent, bool verbose, bool quiet, bool imp->active = 0; imp->limit = std::thread::hardware_concurrency() * percent; imp->phys_active = 0; + +#ifdef __APPLE__ + struct host_basic_info hostinfo; + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; + int result = host_info(mach_host_self(), HOST_BASIC_INFO, reinterpret_cast(&hostinfo), &count); + if (result != KERN_SUCCESS || count != HOST_BASIC_INFO_COUNT) { + fprintf(stderr, "host_info failed\n"); + exit(1); + } + imp->phys_limit = static_cast(hostinfo.max_mem); +#else imp->phys_limit = sysconf(_SC_PHYS_PAGES); imp->phys_limit *= sysconf(_SC_PAGESIZE); +#endif imp->phys_limit *= percent; + sigemptyset(&imp->block); struct sigaction sa; diff --git a/src/regexp.cpp b/src/regexp.cpp index 6fb6a2548..cb63a66de 100644 --- a/src/regexp.cpp +++ b/src/regexp.cpp @@ -133,10 +133,10 @@ static PRIMFN(prim_extract) { RE2_BUG(arg1); int matches = arg0->exp->NumberOfCapturingGroups(); - re2::StringPiece submatch[matches+1]; + std::vector submatch(matches+1); re2::StringPiece input = sp(arg1); - if (arg0->exp->Match(input, 0, input.size(), RE2::ANCHOR_BOTH, submatch, matches+1)) { + if (arg0->exp->Match(input, 0, input.size(), RE2::ANCHOR_BOTH, &submatch[0], matches+1)) { size_t need = reserve_list(matches); for (int i = 0; i < matches; ++i) need += String::reserve(submatch[i+1].size());