Search Results

Search: Posts Made By: DreamWarrior
Forum: Programming 11-06-2012
4,002
Posted By DreamWarrior
I'm fond of this method.... class Single ...
I'm fond of this method....


class Single
{
public:
static Single &getSingle()
{
static Single theSingle;
return theSingle;
}

private:
Single(); // private constructor...
Forum: Programming 11-06-2012
29,725
Posted By DreamWarrior
Beaten...lol. That's what I was going to post. ...
Beaten...lol. That's what I was going to post. Malloc 1gb of memory does "nothing" until you touch the pages. Replace that statement with, for example, calloc, though, and...well...just go ahead...
Forum: Programming 11-06-2012
6,291
Posted By DreamWarrior
Mine. Why?
Mine. Why?
Forum: Programming 11-05-2012
6,291
Posted By DreamWarrior
C++ abstract (singleton) factory implementation...
I want to create an abstract factory template which will allow me to pass in an "ID" for a subclass and return the singleton instance of that class stored in the factory. It'd be easy to adapt for...
Forum: Programming 01-30-2012
2,412
Posted By DreamWarrior
Not really, because I have no idea what the dlist...
Not really, because I have no idea what the dlist structure looks like. But, I'd guess you have a head pointer in dlist. So:

if (p == NULL)
{
newPosition->next = l->head;
l->head =...
Forum: Programming 01-30-2012
2,412
Posted By DreamWarrior
I'm not sure what you want the "dlist_position"...
I'm not sure what you want the "dlist_position" to be, but what you're doing in that insert won't work at all. How you have it coded right now is very likely to crash when executing...
Forum: Programming 01-30-2012
2,570
Posted By DreamWarrior
Is the output of the "time" command not what...
Is the output of the "time" command not what you're looking for? You can execute it as:


time <executable_name> <args>
Forum: Programming 01-30-2012
2,412
Posted By DreamWarrior
I'm only guessing without line numbers, but I'd...
I'm only guessing without line numbers, but I'd bet the compiler is complaining about this line:


p = dlist_insert(list, p, element[0]);


Because p is, indeed, uninitialized when being...
Forum: Programming 01-30-2012
4,064
Posted By DreamWarrior
First, I'm going to let you know that there is A...
First, I'm going to let you know that there is A LOT wrong with these programs. I'll go into a few things, then answer your questions:

1) First and foremost, an integer...
Forum: Programming 01-20-2012
3,111
Posted By DreamWarrior
edit: nevermind...your compiler's parser is more...
edit: nevermind...your compiler's parser is more off than my mental parser, lol.
Forum: Programming 12-16-2011
75,808
Posted By DreamWarrior
That's why you use sigaction; if you want the...
That's why you use sigaction; if you want the system call to restart after signal then supply the SA_RESTART flag, otherwise, don't and you'll get SIGINT. While the default behavior may be different...
Forum: Programming 12-16-2011
41,251
Posted By DreamWarrior
man 2 chmod It describes the modes there.
man 2 chmod

It describes the modes there.
Forum: Programming 12-16-2011
75,808
Posted By DreamWarrior
sleep doesn't send SIGALRM. At any rate,...
sleep doesn't send SIGALRM.

At any rate, pause will work, I've seen people do:


for ( ; ; ) sleep(UINT_MAX);


And then, as mentioned, pthread_kill can wake it provided the thread hasn't...
Forum: Programming 12-16-2011
7,304
Posted By DreamWarrior
Maybe it's this: while (fscanf(fptr,...
Maybe it's this:


while (fscanf(fptr, "%lf", &fArray[i]) != EOF);

You have a semi colon after the while, so you're reading in every line from the file until EOF, then looping and doing it...
Forum: Programming 12-16-2011
41,251
Posted By DreamWarrior
Did you change the sizeof? You don't even use...
Did you change the sizeof? You don't even use buffer in the first program, so you can get rid of that. Then when you shmget pass (sizeof(int) * 2) as the size argument.

Also, to the third...
Forum: Programming 12-16-2011
41,251
Posted By DreamWarrior
You're welcome. That will work, there is...
You're welcome.

That will work, there is also the ftok function. I've seen hard-coded keys and ftok used, more often the former (don't know why, really). Another method I've seen is a hard-coded...
Forum: Programming 12-15-2011
41,251
Posted By DreamWarrior
Yes, you either need a key or to pass the...
Yes, you either need a key or to pass the segment's ID. IPC_PRIVATE is meant to be used between two programs that can pass the ID, either because one forked the other and the ID is resident, or...
Forum: Programming 12-15-2011
3,512
Posted By DreamWarrior
As others said, you should be very wary of doing...
As others said, you should be very wary of doing work in a signal handler. There is a short list of async-signal safe functions...
Forum: Programming 11-10-2011
2,062
Posted By DreamWarrior
The real problem is that when you say "*str =...
The real problem is that when you say "*str = "hello there"" what you're telling the compiler is to set the value of the memory location pointed to by str to the address of the string "hello there"...
Forum: Programming 11-10-2011
1,616
Posted By DreamWarrior
If you remove the virtual keyword then the...
If you remove the virtual keyword then the function doesn't get put into the virtual function table. Therefore, I believe any calls to the function are bound to the function within the type's class....
Forum: Programming 11-01-2011
4,471
Posted By DreamWarrior
Agreed with Corona, and I was going to make the...
Agreed with Corona, and I was going to make the same statement, but not seeing the rest of the code, and under the assumption it works, I figured maybe it was memory mapping the file to some fixed...
Forum: Programming 11-01-2011
1,928
Posted By DreamWarrior
I think that's probably one of the most...
I think that's probably one of the most misunderstood things about floats. Using the equals operator on them is generally a bad idea. As Corona pointed out, you should test within a range of the...
Forum: Programming 10-26-2011
6,401
Posted By DreamWarrior
This also sounds like homework, and my bet is...
This also sounds like homework, and my bet is that they don't want you to call the system's copy function, rather they want you to open the two files in binary and read from one and write to the...
Forum: Programming 10-24-2011
17,020
Posted By DreamWarrior
I'm not sure what you're getting at here.... Are...
I'm not sure what you're getting at here.... Are you saying the reason to call memset is to assist the VMM in keeping up with a fast transfer?
Forum: Programming 10-22-2011
3,853
Posted By DreamWarrior
z = (z < 0) ? z + 2*r*cos(theta) : z -...
z = (z < 0) ? z + 2*r*cos(theta) : z - 2*r*cos(theta);

Or, if you'd like:

z += (z < 0) ? 2*r*cos(theta) : -2*r*cos(theta);


edit: ugh; beaten, twice over, lol.
Showing results 1 to 25 of 171

 
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy