repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 761303824752effaa3d7c9f9b2eeb0548c912045: path_to: revision_to:
commit 761303824752effaa3d7c9f9b2eeb0548c912045 Author: Marc LehmannDate: Thu May 17 20:05:55 2012 +0000 *** empty log message *** diff --git a/src/rxvtfont.C b/src/rxvtfont.C
--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -1787,14 +1787,7 @@ found:
if (!fmap[hi])
{
- // we use [1] here because C++ has no separate new and new [] forms,
- // and pagemap is char[256], so new incorrectly assumes we want to
- // allocate an array of chars instead of a single pagemap.
- // we can either cast the resulting pointer to (pagemap *) or
- // allocate an array of pagemaps, returning a pointer to the first member
- // this is no extra overhead, as new even allocates an array for
- // "new pagemap"
- fmap[hi] = new pagemap[1];
+ fmap[hi] = new pagemap;
memset (fmap[hi], 0xff, sizeof (pagemap));
}
diff --git a/src/rxvtfont.h b/src/rxvtfont.h
--- a/src/rxvtfont.h +++ b/src/rxvtfont.h @@ -108,7 +108,18 @@ private: simplevecfonts; const rxvt_fallback_font *fallback; - typedef unsigned char pagemap[256]; + // this once was a "typedef xxx pagemap[256] + // but c++ arrays are not normal types, and cnanot be + // put into containers, new doesn't work for them etc. etc. + // so we wrap out array into an objetc that acts like one. doh. + // example: C++ has no separate new and new [] forms, + // and if pagemap is char[256], new incorrectly assumes we want to + // allocate an array of chars instead of a single pagemap. + struct pagemap + { + unsigned char cppsucks[256]; + unsigned char &operator [](int i) { return cppsucks [i]; }; + }; vector fmap; void clear ();
-----END OF PAGE-----