[QUOTE=areolop;41705578]Sorry guys, I'm not a programmer by any means, but am apart of a team that is developing low-level police database interface software. We've came to a stalemate on how to get the best security not only for transmission of the data, but the actual database itself.
We already Salt passwords and are getting a SSL certificate, but we need to be able to have assurance that our SQL database itself is not susceptible to attacks and if it were, how to protect the data inside without them being able to read it in plain english.
Any tools, techniques, open-source projects out there that can encrypt/secure a database?[/QUOTE]
I'm assuming you're not exposing your database to the client, and using an interface on the server that escapes any control characters/uses stored procedures to avoid injection attacks (and is not exploitable itself. Managed languages are a bit more secure because they prevent buffer overflow attacks automatically, otherwise be sure the length of the supplied data is always checked before being written to a static-length buffer. Not doing that basically means anyone can run anything on the machine (with a few limitations)). This is pretty much industry standard though, so it's likely to be already implemented by the developers.
Deactivate [b]all[/b] other services visible from the network, if one of them can be exploited the data is available to an attacker.
Securing the database against physical access is difficult, but not impossible.
You can encrypt the whole hard-drive, so every time the system is started a password must be entered. Then you just have to avoid anyone getting access to the running system (I'm sure there's a solution for connecting a strong enclosure to a breaker) or cooling it enough to "freeze" the password in memory (as the data degrades over time after shutting down the system, depending on temperature. It's a well known attack with existing tools).
If all the software is secure and the database system doesn't accept key presses after entering the password and locking the enclosure it should be safe.
It may be a good idea to run the database on a different computer than the public interface, but I'm not a security professional so I'm not sure how effective it is. It certainly helps if the interface can be exploited, but only against what the interface doesn't have rights to do.
Encrypting the database without having to enter the password during start-up is probably pretty useless, it could help if the interface decrypt/encrypts it on-the-fly and the database is reachable from an unauthorized system, but it ideally should be physically connected in such a way that only the interface can reach it.
(If your interface system can be exploited all other security measures become relatively moot, as it needs to have access to the data and the outer network.)
[editline]edit[/editline]
If you can't lock down the database server, it should be possible to use a secure encryption/decryption system: [URL="http://security.stackexchange.com/a/555"]http://security.stackexchange.com/a/555[/URL]
[URL="http://security.stackexchange.com"]security.stackexchange.com[/URL] has a lot of questions and answers that deal with similar situations, it may help in case you have overlooked something.
Can someone explain how to code this in C++? I'm trying to find out how the random dialogs appear during combat and when you speak to generic NPCs in Jagged Alliance 2 and change it to appear above an NPCs head, like this.
[IMG]http://img.gfx.no/534/534328/Fallout_01.jpg[/IMG]
[QUOTE=Tamschi;41707874]I'm assuming you're not exposing your database to the client, and using an interface on the server that escapes any control characters/uses stored procedures to avoid injection attacks (and is not exploitable itself. Managed languages are a bit more secure because they prevent buffer overflow attacks automatically, otherwise be sure the length of the supplied data is always checked before being written to a static-length buffer. Not doing that basically means anyone can run anything on the machine (with a few limitations)). This is pretty much industry standard though, so it's likely to be already implemented by the developers.
Deactivate [b]all[/b] other services visible from the network, if one of them can be exploited the data is available to an attacker.
Securing the database against physical access is difficult, but not impossible.
You can encrypt the whole hard-drive, so every time the system is started a password must be entered. Then you just have to avoid anyone getting access to the running system (I'm sure there's a solution for connecting a strong enclosure to a breaker) or cooling it enough to "freeze" the password in memory (as the data degrades over time after shutting down the system, depending on temperature. It's a well known attack with existing tools).
If all the software is secure and the database system doesn't accept key presses after entering the password and locking the enclosure it should be safe.
It may be a good idea to run the database on a different computer than the public interface, but I'm not a security professional so I'm not sure how effective it is. It certainly helps if the interface can be exploited, but only against what the interface doesn't have rights to do.
Encrypting the database without having to enter the password during start-up is probably pretty useless, it could help if the interface decrypt/encrypts it on-the-fly and the database is reachable from an unauthorized system, but it ideally should be physically connected in such a way that only the interface can reach it.
(If your interface system can be exploited all other security measures become relatively moot, as it needs to have access to the data and the outer network.)
[editline]edit[/editline]
If you can't lock down the database server, it should be possible to use a secure encryption/decryption system: [URL="http://security.stackexchange.com/a/555"]http://security.stackexchange.com/a/555[/URL]
[URL="http://security.stackexchange.com"]security.stackexchange.com[/URL] has a lot of questions and answers that deal with similar situations, it may help in case you have overlooked something.[/QUOTE]
Thanks for the reply. Yea, we're looking to secure the SQL database that we have from outside bruting/ other means. The links you've sent are very helpful.
Does anyone here know how make keys like this with a smaller number/sign in the upper right corner in Android ?
Also are the shift and backspace icons system resource drawables, or just custom drawables ?
[quote][img]http://eurodroid.com/pics/swype_android_app_keyboard.png[/img][/quote]
In a C++ class is it alright to use namespaces group together related constants?
I have a MAX_PLAYER_COUNT and a MIN_PLAYER_COUNT const int in my Tron class, but I would prefer they be grouped in nested namespaces, so instead of:
[code]
Tron::MAX_PLAYER_COUNT;
Tron::MIN_PLAYER_COUNT;
[/code]
I would use:
[code]
Tron::PlayerCount::MAX;
Tron::PlayerCount::MIN;
[/code]
or something similar (as I'm not sure you can actually nest namespaces like this), but this seems odd for some reason. What do you recommend?
[editline]4th August 2013[/editline]
Also, is there a standard library function to clamp a variable between to values? Something like:
[code]
template <typename T>
inline T clamp(T val, T min, T max) {
return std::min(std::max(min, val), max);
}
[/code]
namespaces do nest like that, but it does seem odd to me too to use them for that purpose.
You could use an enum class, they provide scoping (unlike plain enums).
And I don't think there's a clamp-function in the standard library, but [url=http://www.boost.org/doc/libs/1_54_0/libs/algorithm/doc/html/algorithm/Misc.html#the_boost_algorithm_library.Misc.clamp]there is in Boost[/url].
[QUOTE=ZeekyHBomb;41713538]namespaces do nest like that, but it does seem odd to me too to use them for that purpose.
You could use an enum class, they provide scoping (unlike plain enums).
And I don't think there's a clamp-function in the standard library, but [URL="http://www.boost.org/doc/libs/1_54_0/libs/algorithm/doc/html/algorithm/Misc.html#the_boost_algorithm_library.Misc.clamp"]there is in Boost[/URL].[/QUOTE]
I considered enum (class), but it is the underlying value that I'm interested in, and with enum's that is more or less considered an implementation detail. I have seen before that an anonymous namespace is a common way of defining file-specific constants, and thought it would be easy to extend to named namespaces, but when I did it seemed perhaps more awkward than just postfixing each constant.
And good old boost is always there to save the day, I just wondered why the standard library would provide other comparison functions (like min and max) but not something so common as clamp.
2 kinda long C++ questions,
1st, for debugging purposes I wish to keep track of memory usage, I asked a while back the best way to do this and was given the following code:
[cpp]
#include <cstring>
#include <cstdlib>
#include <new>
static unsigned long long bytesUsed;
static int magicNumber = 5551234;
struct MemoryChunk
{
int myCreation;
int size;
};
//Overrides the new operator and adds the size of the variable to bytesUsed
void* operator new (size_t size)
{
bytesUsed += size;
void *p = malloc(sizeof(MemoryChunk) + size);
if(!p)
throw std::bad_alloc();
MemoryChunk chunk = {magicNumber, size};
memcpy(p, &chunk, sizeof(chunk));
return (char *)p + sizeof(MemoryChunk);
}
void operator delete (void *p)
{
MemoryChunk *chunk = (MemoryChunk *)p - 1;
if(chunk->myCreation == magicNumber)
{
bytesUsed -= chunk->size;
free(chunk);
}
else
{
free(p);
}
p = NULL;
}
[/cpp]
Is this correct? Also, should this be in a header that all files include? or can it just be in any cpp file?
2nd, I am trying to implement a system for hotswapping files, AKA reload a file on the go.
For it I have written the following:
[cpp]
time_t Util::GetModificationTime(const std::string &filename)
{
time_t elapsedSinceTimeStamp = 0;
struct stat attrib;
stat(filename.c_str(), &attrib);
elapsedSinceTimeStamp = attrib.st_mtime;
return elapsedSinceTimeStamp;
}
[/cpp]
Which seems to work on the very basic tests I did, but do you think it could lag the program by quite a bit if it is checking for modifications on every loop? I think ideally I would want to check every 10 or 60 loops/frames essentially that should keep it smooth and would only add a couple of seconds delay for the reload.
Do both these codes look OK? my main focus at the moment is writting it to be readable and cross-platform.
[editline]5th August 2013[/editline]
Oh and another quick one,
I have this defined in my Utilities header
[cpp]#define PrintGLErrors() PrintGLErrorsFromLine( __FILE__, __LINE__)[/cpp]
so that all I need to do is PrintGLErrors(); from anywhere and it will automatically give it the filename and line, but will this pull the line and name of the header its defined in? or will it work as I expect and giev the the line and name where PrintGLErrors() gets called?
The code is more or less correct (some std:: missing), although it only implements new and delete, while there's also new[], delete[] and the nothrow variants.
And personally I think the memcpy looks awkward for that usage. You can just cast the pointer to a MemoryChunk reference and set myCreation and size manually.
You update bytesUsed even if malloc() returns nullptr, which is probably not what you want.
delete nullptr; is legal and shouldn't crash (or more precisely: invoke undefined behavior). I think your operator delete would though.
And I find it weird that p is free()'d if the magic number does not match; that seems like it would have to be accidentally overridden by an underflow bug. And setting p to nullptr doesn't do anything useful.
You should put it in a cpp file.
Most OSs provide the userland with subscription for events for file (and directory) changes. There is not standard C++ functionality which provides access to that though. A quick search turned up [url=simplefilewatcher]https://code.google.com/p/simplefilewatcher/[/url].
And your macro will work as expected.
[editline]5th August 2013[/editline]
[QUOTE=Rayjingstorm;41713806]I considered enum (class), but it is the underlying value that I'm interested in, and with enum's that is more or less considered an implementation detail. I have seen before that an anonymous namespace is a common way of defining file-specific constants, and thought it would be easy to extend to named namespaces, but when I did it seemed perhaps more awkward than just postfixing each constant.[/QUOTE]
You can specify the underlying type in C++11.
But if you meant that you want the type of the constants to not be an enum-type I guess namespaces are the way to go then.
[QUOTE=ZeekyHBomb;41714272]The code is more or less correct (some std:: missing), although it only implements new and delete, while there's also new[], delete[] and the nothrow variants.
And personally I think the memcpy looks awkward for that usage. You can just cast the pointer to a MemoryChunk reference and set myCreation and size manually.
You update bytesUsed even if malloc() returns nullptr, which is probably not what you want.
delete nullptr; is legal and shouldn't crash (or more precisely: invoke undefined behavior). I think your operator delete would though.
And I find it weird that p is free()'d if the magic number does not match; that seems like it would have to be accidentally overridden by an underflow bug. And setting p to nullptr doesn't do anything useful.
You should put it in a cpp file.[/QUOTE]
I think the freeing of p was done so that if by chance something was created not using my new declaration it would behave as expected, but then again if it wasnt created using my new then it shouldnt be deleted using my delete..
Would this be better?
[cpp]void* operator new (size_t size)
{
void *p = std::malloc(sizeof(MemoryChunk) + size);
if(!p)
throw std::bad_alloc();
bytesUsed += size;
((MemoryChunk &)p).myCreation = magicNumber;
((MemoryChunk &)p).size = size;
return (char *)p + sizeof(MemoryChunk);
}
void operator delete (void *p)
{
if(p == NULL)
{
return;
}
MemoryChunk *chunk = (MemoryChunk *)p - 1;
if(chunk->myCreation == magicNumber)
{
bytesUsed -= chunk->size;
std::free(chunk);
}
else{
std::free(p);
}
p = NULL;
}[/cpp]
Any advice how I could do the same for new[], delete[] ?
[cpp]((MemoryChunk &)p)[/cpp]
You're casting a pointer to a reference. Either cast to p to MemoryChunk* and use -> or cast into a variable and dereference.
[cpp]void* operator new (const std::size_t size)
{
void *const p = std::malloc(sizeof(MemoryChunk) + size);
if(!p)
throw std::bad_alloc();
bytesUsed += size;
MemoryChunk &mc = *reinterpret_cast<MemoryChunk*>(p);
mc.myCreation = magicNumber;
mc.size = size;
return &mc + 1;
}[/cpp]
This is the code I'd use.
I like const.
You're inconsistent in checking for null pointers; in new you use !p, in delete you use p == NULL.
And I believe the parentheses attached to the else is just a copy&paste error.
Setting p to NULL at the end of delete still doesn't do anything. It'll be optimized away as soon as you turn on the first optimization level.
For new[] and delete[] do do the same thing, just with new[] and delete[] as function name.
You can also just delgate to new and delete:
[cpp]void* operator new[] (const std::size_t size)
{
return new(size);
}
void operator delete[] (void *const p)
{
delete(p);
}[/cpp]
[editline]5th August 2013[/editline]
Oh, and I'd have the size-field of MemoryChunk as std::size_t.
I know people might not like a platform specific solution but you could always get your memory usage from the OS. Not that there's anything particularly wrong with overriding new, but you do also have to guarantee that all memory allocation comes from new.
How accurate would that be?
In terms of shared memory from dynamically linked librares, reserved but unused memory and more memory allocated by the OS than requested?
Also another thing you could do is passing additional parameters to new, so you can pass in either an enumeration value or a string indicating what the allocated memory is used for. Then you can for example see what sub-system allocated how much heap memory.
[QUOTE=ZeekyHBomb;41719507]How accurate would that be?
In terms of shared memory from dynamically linked librares, reserved but unused memory and more memory allocated by the OS than requested?
Also another thing you could do is passing additional parameters to new, so you can pass in either an enumeration value or a string indicating what the allocated memory is used for. Then you can for example see what sub-system allocated how much heap memory.[/QUOTE]
Yeah I see your point that it is not counting the same thing. It wouldn't harm to do both. Also it's only useful for the whole memory usage, I agree about more fine grained counting if it's important to your program.
I'm having some trouble writing a makefile that will create a jar using my eclipse project and also include all the jars that the project depends on.
I'm trying to set it up so that the user can say 'make' in the top level of the project, and have a jar pop up that functions pretty much exactly as if they had used the 'export' command in eclipse.
This is more a quality of life thing, removing the need to use eclipse if the client doesn't want to.
I've looked at a couple examples, but unfortunately I'm a bit terrible at makefiles so I didn't understand how to modify them to fit my goal.
What is the part you're having problems with?
[editline]5th August 2013[/editline]
The general structure should probably be something like this.
Is there something like pkg-config for java? I just called it java-config.
I assume that you must set the dependency-flags for javac.
[code]#set variables
JAVAC:=javac
JAVAC_FLAGS:=
JAR:=jar
JAR_FLAGS:=
#invoke java-config for dependencies
DEP1_FLAGS:=$(shell java-config external-dep1)
DEP2_FLAGS:=$(shell java-config external-dep2)
#add dependency-flags to javac-flags
JAVAC_FLAGS:=$(JAVAC_FLAGS) $(DEP1_FLAGS) $(DEP2_FLAGS)
#primary target
all: myprog.jar
#define (internal) dependencies for myprog
myprog.jar: a.class b.class c.class
#how to build a .jar file
%.jar:
jar cf $@ $(JAR_FLAGS) $<
#how to build a .class file
%.class: %.java
javac $(JAVAC_FLAGS) $<[/code]
[QUOTE=ZeekyHBomb;41719507]How accurate would that be?
In terms of shared memory from dynamically linked librares, reserved but unused memory and more memory allocated by the OS than requested?
Also another thing you could do is passing additional parameters to new, so you can pass in either an enumeration value or a string indicating what the allocated memory is used for. Then you can for example see what sub-system allocated how much heap memory.[/QUOTE]
Would there be any way to achieve the ability to pass in an argument to new that to be able to tell the type and also keep the ability to easely switch between using the overriden new and the default one?
Does the overloading of new and delete need to be in every c++ file?
I had them in their own C++ files however when I tried out printing the bytesUsed from main after creating some objects it still said 0, yet when I moved the overload into the main file it went up
Also, what did you mean by:
And I believe the parentheses attached to the else is just a copy&paste error. there is no parenthesis on the else :S
[QUOTE=Richy19;41724919]Would there be any way to achieve the ability to pass in an argument to new that to be able to tell the type and also keep the ability to easely switch between using the overriden new and the default one?[/QUOTE]
Sure
[cpp]#ifdef MY_NEW
void* operator new (const std::size_t size)
{
void *const p = std::malloc(sizeof(MemoryChunk) + size);
//stuff
}
#endif
void* operator new (const std::size_t size, const int param)
{
#ifdef MY_NEW
//do param stuff
#else
static_cast<void>(param);
#endif
return new(size);
}[/cpp]
[QUOTE]Does the overloading of new and delete need to be in every c++ file?
I had them in their own C++ files however when I tried out printing the bytesUsed from main after creating some objects it still said 0, yet when I moved the overload into the main file it went up[/QUOTE]
Just tested it, works fine for me. Seperate new.cpp containing overloaded new and delete and main.cpp just containing main() and a call to new and delete.
Make sure you are indeed building with that file.
[QUOTE]Also, what did you mean by:
And I believe the parentheses attached to the else is just a copy&paste error. there is no parenthesis on the else :S[/QUOTE]
Sorry, I meant curly brackets.
So, gravity physics, trying to get circular
[code]public Vector2 gravityPull(Vector2 Objectposition, int objectmass, Vector2 forceVector2)
{
Vector2 forcevector = Vector2.Zero;
float distance = Vector2.Distance(this.position, Objectposition);
float force = (float)(6.6720e-08 * ((this.mass * objectmass) / distance));
float Centripetalforce = (float)(objectmass * (Math.Pow(Vector2.Distance(Vector2.Zero, forceVector2), 2) / distance));
forcevector = new Vector2(this.position.X - Objectposition.X, this.position.Y - Objectposition.Y);
forcevector.Normalize();
forcevector *= force + Centripetalforce;
return forcevector;
}[/code]
it just dissapears off to NaN after like 5 frames. I could use some help with this
I'm only have like 50% idea of what i am doing, gravitational pull works fine, but that just caused it to go off like this
[img]https://dl.dropboxusercontent.com/u/45707598/Drawings/Badorbit.png[/img]
Now i have to work with this centripetal force which i dont really know what it is and how to implement into the code correctly.
The unit of your centripetal force is
kg*(N^2/m) = kg*((kg*m/s^2)^2/m) = kg*((kg^2*m^2*s^-4)/m) = kg^3*m*s^-4
Which is certainly not kg*m/s^2 = N.
Besides gravity is the centripetal force.
I'm not sure what the issue in your picture is. Seems more or less correct.
[QUOTE=ZeekyHBomb;41725856]The unit of your centripetal force is
kg*(N^2/m) = kg*((kg*m/s^2)^2/m) = kg*((kg^2*m^2*s^-4)/m) = kg^3*m*s^-4
Which is certainly not kg*m/s^2 = N.
Besides gravity is the centripetal force.
I'm not sure what the issue in your picture is. Seems more or less correct.[/QUOTE]
This is how i want my stuff to orbit.
[img]https://dl.dropboxusercontent.com/u/45707598/Drawings/goodorbit.png[/img]
This is how wikipedia descries centirpetal force
[img]https://upload.wikimedia.org/math/d/f/8/df86712e000fe347516b8f39b9490815.png[/img]
Then you need the right masses and initial positions and velocity. It doesn't always end up like a perfect orbit.
See [url=https://en.wikipedia.org/wiki/Orbital_mechanics]Wikipedia[/url].
[QUOTE=ZeekyHBomb;41725077]Just tested it, works fine for me. Seperate new.cpp containing overloaded new and delete and main.cpp just containing main() and a call to new and delete.
Make sure you are indeed building with that file.[/QUOTE]
Just to make sure that im not doing something silly, as I tried it again and recreated the project but still the number doesnt change.
I have the following:
DebugOperators.hpp [url]http://pastebin.com/Ypqm4rGS[/url]
DebugOperators.cpp [url]http://pastebin.com/tsFYARDb[/url]
Main.cpp [url]http://pastebin.com/fXAaC9EU[/url]
just outputs 0 0 0 0 0
Also are you sure you need to override new[]? a few articles I have read only mention new, delete and delete[]. also when overriding new[], I got an error about there not being a new() that takes 1 argument.
Oh and, dont suppose you have any idea why in new it returns &mc + 1; and then when deleting it (MemoryChunk *)p - 1; ?
Could I just remove the +1 and -1?
PS: Thanks for all your help :) your pretty much maintaining WDYNHW by yourself these last few days
[editline]5th August 2013[/editline]
Just fixed the issue with the size not updating, I made it an extern and set it to 0 in the cpp and it fixed it :)
[QUOTE=ZeekyHBomb;41726006]Then you need the right masses and initial positions and velocity. It doesn't always end up like a perfect orbit.
See [url=https://en.wikipedia.org/wiki/Orbital_mechanics]Wikipedia[/url].[/QUOTE]
I know, but the orbit is fucked up because I dont know the right calculaitons, this is what real stable an eccentric orbits look like kinda
[t]http://earthobservatory.nasa.gov/Features/OrbitsCatalog/images/ellipse_diagram.png[/t]
Notice how they all form full circles, mine however, doesn't, it will just spin around like mad...
[QUOTE=Richy19;41726009]Just to make sure that im not doing something silly, as I tried it again and recreated the project but still the number doesnt change.
I have the following:
DebugOperators.hpp [url]http://pastebin.com/Ypqm4rGS[/url]
DebugOperators.cpp [url]http://pastebin.com/tsFYARDb[/url]
Main.cpp [url]http://pastebin.com/fXAaC9EU[/url]
just outputs 0 0 0 0 0
Also are you sure you need to override new[]? a few articles I have read only mention new, delete and delete[]. also when overriding new[], I got an error about there not being a new() that takes 1 argument.
Oh and, dont suppose you have any idea why in new it returns &mc + 1; and then when deleting it (MemoryChunk *)p - 1; ?
Could I just remove the +1 and -1?
PS: Thanks for all your help :) your pretty much maintaining WDYNHW by yourself these last few days
[editline]5th August 2013[/editline]
Just fixed the issue with the size not updating, I made it an extern and set it to 0 in the cpp and it fixed it :)[/QUOTE]
You should be doing
[cpp]extern unsigned long long BytesUsed;[/cpp]
In the header, and
[cpp]unsigned long long BytesUsed;[/cpp]
In the implementation file.
And you seem to be correct about not needing seperate new[] and delete[] operators, it'll just take the 'normal' ones, although overloading too them works fine for me.
You return &mc + 1 because you want the callee to have a pointer to where he can begin writing memory. If you return &mc you'd write over your MemoryChunk-header.
And when deleting your do -1 to go a step back to your header.
And to be consistent with the usage of pointers or references, you can dereference the pointer in delete() to get a MemoryChunk&.
[editline]6th August 2013[/editline]
[QUOTE=Fatfatfatty;41726075]I know, but the orbit is fucked up because I dont know the right calculaitons, this is what real stable an eccentric orbits look like kinda
[t]http://earthobservatory.nasa.gov/Features/OrbitsCatalog/images/ellipse_diagram.png[/t]
Notice how they all form full circles, mine however, doesn't, it will just spin around like mad...[/QUOTE]
Your gravity code, if you take out the centripetal force code, looks correct.
If your initial velocity is correct in direction and magnitude it should work. Floating-point inaccuracies shouldn't throw it too far off I think.
[editline]6th August 2013[/editline]
Also your timesteps shouldn't be too big.
[editline]6th August 2013[/editline]
[QUOTE=E3245;41708135]Can someone explain how to code this in C++? I'm trying to find out how the random dialogs appear during combat and when you speak to generic NPCs in Jagged Alliance 2 and change it to appear above an NPCs head, like this.
[IMG]http://img.gfx.no/534/534328/Fallout_01.jpg[/IMG][/QUOTE]
This is really specific the the game engine. If there's an active community around the JA2 source code you should ask there.
Otherwise, look where else in the game text appears right in the world. If there is no such effect, try piecing something together with the text-rendering from UI elements and world-effects.
Some linear algebra, like projecting points form a 3D space to a 2D plane will probably be useful.
this isn't a floating point innacuracy, this is bulltshit
[img]https://dl.dropboxusercontent.com/u/45707598/orbitWTF.png[/img]
maybe i should go ask a physicist
[QUOTE=ZeekyHBomb;41726116]You return &mc + 1 because you want the callee to have a pointer to where he can begin writing memory. If you return &mc you'd write over your MemoryChunk-header.
And when deleting your do -1 to go a step back to your header.
And to be consistent with the usage of pointers or references, you can dereference the pointer in delete() to get a MemoryChunk&.[/QUOTE]
Ahh ofcourse, that makes sense. Tho if I start adding to the memorychunk struct should I use + sizeof(memorychunk) > or is it using pointer arithmetic there and automatically advancing by 1size of memorychunk?
[editline]6th August 2013[/editline]
And I preffer keeping it all as pointers, which I believe would mean changing the stuff in new to:
[cpp] MemoryChunk *mc = (MemoryChunk*)p;
mc->myCreation = magicNumber;
mc->size = size;
return mc + 1;[/cpp]
The pointer arithmetic advances it by the size of the type, you'd have to cast it to char* to go byte-by-byte.
And the code-snipped you posted looks correct, albeit not prettily aligned.
Fixed my orbits, it was just that the gravity well was static but the object had fairly high mass in comparison to the "planet" which caused it to move oddly
[img]https://dl.dropboxusercontent.com/u/45707598/goodorbit.png[/img]
[QUOTE=Fatfatfatty;41726322]this isn't a floating point innacuracy, this is bulltshit
[img]https://dl.dropboxusercontent.com/u/45707598/orbitWTF.png[/img]
maybe i should go ask a physicist[/QUOTE]
rk4
Sorry, you need to Log In to post a reply to this thread.