Wednesday, 13 April 2011

Holy Moly...

I'm not a religious man, but I am a technophile.. and boy has this got me gob smacked:

Friday, 8 April 2011

Re-constructive Archaeology

Tonight I want to update the firmware and BIOS eeproms in my Dell Power Edge servers... this means I needed to carry out some re-constructive archaeology... You know, the kind of archaeology where people spend vast time and energies in living the lives of people from antiquity to feel and experience the situation?  Its a bit like L.A.R.Ping but for history, rather than games...

So, what did I do, you might ask... Well... I went out... and bought a pack of 3.5" Floppy Disks!!!!

Yes, you can still buy them (if you look hard enough).

The reason for having to buy them is a bit galling, I had to because all the ones I have in a disk tray at home seem to have degraded beyond the point of use... this is worrying as they're in the same box as a whole bunch of Atari ST software, which is on 3.5" DSDD disks... these PC DSHD floppies are a lot younger than the ST ones... which means my ST disks are probably utterly useless... (sob).

Tuesday, 5 April 2011

Temporary File names in C & C++ in Windows and Linux

So, I ran into a little bit of a programming problem involving the C call “tmpnam” which is used to generate you a temporary file name in C and C++. It's not a safe call, because other libraries and applications might call “tmpnam” before you get to use the name given, and they might grab the same file name. But my code needed to generate just a file name... so this will suffice for me (I'll so checking etc. myself).

Anyway, the problem comes up when, in a mix of brain-dead and bad document mode I do this:

char* l_temporaryBuffer = new char[L_tmpnam];
int l_error = tmpnam (l_temporaryBuffer, l_tmpnam);

It leaked memory, in fact it leaked 12 bytes per call, and I was just so brain frazzled at 2am last night that I couldn't wrap my head around why, in the cold light of day however I know why, its because I'm a cock, the 12 bytes were from this buffer... you don't need to assign memory to the buffer you pass in, tmpnam stores the resultant string in a static location.

This was painfully demonstrated when I tried to delete l_temporaryBuffer and was promptly told I had corrupted my application's heap.

So, the correct way of using tmpnam, on Windows and Linux is:

char* l_ptrBuffer;
l_ptrBuffer = tmpnam(NULL);

Or if you're going to use windows you'll likely get a warning that tmpnam is unsafe, and if like me you heed the advice of your warnings (as you all should) you'll want to use tmpnam_s, so on Windows the corrected code is:

char *l_ptrBuffer;
int l_error = tmpnam_s (l_ptrBuffer, L_tmpnam);
if ( error == 0 )
{
    // use the buffer it's valid
}
else
{
    // Scream blue murder the file name is invalid
}

What you should never do is delete[] l_ptrBuffer. In this code, it's not your string to delete, its a static in your runtime.

Likewise if you use tmpnam and get a heap corruption, it maybe because you are disposing of memory which is not yours. Beware.

Thursday, 31 March 2011

My Dream

I had the weirdest dream last night...

I dreamt I was in a field on the edge of a rocky cliff top, which was festooned with washing lines, each holding a brilliantly white sheets.... just before dawn.

As I walked through the white sheets the ground changed from rocks to paving stones, yellow sand stone ones... then I saw a man, in a white vest and like sailors deck trousers, all perfectly white... As I came right up behind him he turned his head to see who I was, and suddenly from behind him, behind a sheet rushed a man in black and grey, who stabbed and stabbed and stabbed the man in the white...

The man in black then fled and the man in white was crawling on his hands and knees, red staining his now tattered clothes which hung from his skinning limbs... he had white hair and bright blue eyes.. which now bulged with shock and were blood shot... but he crawled...

He crawled through the sheets moving in the wind, each time he touched a sheet it was stained vibrant red.

Then he got into the open moving air of the cliff top, and his hair was blowing in the wind... blood dripping from his finger-tips, he precariously stood, and watched the sun rise, to triumphant music playing... the blood dropping, his eyes weeping in the light of the new born day as he stared at the rising red orange and yellow.

And a voice said "This is your dawn".

Then he fell from the cliff.

Sunday, 27 March 2011

Is it a Char, or a Car?

I've never been a huge fan of American English, it has annoyances, it imposed itself over the planet and it sometimes is plainly wrong... not that British (the Queens) English is better, but at least British English has a heritage it's not just changing for the sake of change...

And, one change for the sake of change, which I've come across this weekend, is pissing me off...  I'm a programmer, and one of the types of data one can operate with is character data... you can have strings of characters... characters are "char" in most programming languages... character... ch-ar-ac... char... char... like charcoal... like ch-ild... ch...

Yet this yank insists on calling them "CAR"... CAR STAR... for char*... ARGH.

I want to slap him.

Saturday, 19 March 2011

Borland Turbo C++ Lite

So I was rummaging through some old diskettes... you know those plastic things about three and a half inches across, you remember them right?  Yeah, you got some in that box in the attic with a VHS tape and King Tut's Burial Mask...

Anyway, I found some of those, so I borrowed a USB floppy drive from work and guess what I found on the first one I put?

A real blast from the past:


Anyway, as I know Borland have released Turbo C++ into the public domain (but no-one can download the damn thing) and because this is a version distributed through a cover disk for promotional purposes here's a link to Turbo C++ for DOS as a download.

Friday, 11 March 2011

£22.19 for a brand new Samsung CLP-320

Don't worry, this isn't an advert... just worry, this is a bit of bragging.... I just ordered a brand new Samsung CLP-320 Colour Laser Printer...

And it only cost me £22.19.

How did I do this?  Well, I've actually been clearing a load of the shit out of my house and selling it on eBay and building up a little bit of cash in PayPal... And then I've only had to pay the difference of the original price from my PayPal balance.

I actually sold off a lot of my drumming books £30 of them, plus a £10 DVD just today to fund this little jitty... But, I've been wanting to be able to print a decent quality of document for ages...

And when something bugs me, oh boy does it bug me.

I've priced this thing up, read all the reviews, from the honest to the silly to the adoring ones... I event went to visit one in PCWorld today to see what it looks like and feels like and to open all the doors and twist all the knobs and slide all the slide-able bits.

All I need do now is clear up my desk and move my big PC back under the desk (it's been on top since I fitted my new "quieter fans")

As you can see there's a lot going on... 

Speaking of those fans, at some point over the next two days I'll get around to putting up my information and review.