Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fix clang builds #8

Merged
merged 1 commit into from about 3 years ago

2 participants

William Casarin James Halliday
William Casarin
jb55 commented

bigint.cc: Fixed compile errors for compilers complaining about variable-length arrays (invalid C++)

clang fails to compile bigint.cc, this fixes that

James Halliday substack merged commit b5cd783 into from
James Halliday substack closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 13, 2011
William Casarin jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
…ble-length arrays (invalid C++)
b5cd783
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. +10 5 bigint.cc
15 bigint.cc
@@ -203,11 +203,14 @@ Handle<Value>
203 203 BigInt::New(const Arguments& args)
204 204 {
205 205 if(!args.IsConstructCall()) {
206   - Handle<Value> newArgs[args.Length()];
207   - for(int i = 0; i < args.Length(); i++) {
  206 + int len = args.Length();
  207 + Handle<Value>* newArgs = new Handle<Value>[len];
  208 + for(int i = 0; i < len; i++) {
208 209 newArgs[i] = args[i];
209 210 }
210   - return constructor_template->GetFunction()->NewInstance(args.Length(), newArgs);
  211 + Handle<Value> newInst = constructor_template->GetFunction()->NewInstance(len, newArgs);
  212 + delete[] newArgs;
  213 + return newInst;
211 214 }
212 215 HandleScope scope;
213 216 BigInt *bigint;
@@ -217,9 +220,10 @@ BigInt::New(const Arguments& args)
217 220 mpz_t *num = (mpz_t *) External::Unwrap(args[0]);
218 221 bigint = new BigInt(num);
219 222 } else {
  223 + int len = args.Length();
220 224 Local<Object> ctx = Local<Object>::New(Object::New());
221   - Handle<Value> newArgs[args.Length()];
222   - for(int i = 0; i < args.Length(); i++) {
  225 + Handle<Value>* newArgs = new Handle<Value>[len];
  226 + for(int i = 0; i < len; i++) {
223 227 newArgs[i] = args[i];
224 228 }
225 229 Local<Value> obj = js_conditioner->Call(ctx, args.Length(), newArgs);
@@ -228,6 +232,7 @@ BigInt::New(const Arguments& args)
228 232 base = obj->ToObject()->Get(String::NewSymbol("base"))->ToNumber()->Value();
229 233
230 234 bigint = new BigInt(str, base);
  235 + delete[] newArgs;
231 236 }
232 237
233 238 bigint->Wrap(args.This());

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.