Search Results

Search found 23804 results on 953 pages for 'void pointer'.

Page 11/953 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Determining if Memory Pointer is Valid - C++

    - by Jim Fell
    It has been my observation that if free( ptr ) is called where ptr is not a valid pointer to system-allocated memory, an access violation occurs. Let's say that I call free like this: LPVOID ptr = (LPVOID)0x12345678; free( ptr ); This will most definitely cause an access violation. Is there a way to test that the memory location pointed to by ptr is valid system-allocated memory? It seems to me that the the memory management part of the Windows OS kernel must know what memory has been allocated and what memory remains for allocation. Otherwise, how could it know if enough memory remains to satisfy a given request? (rhetorical) That said, it seems reasonable to conclude that there must be a function (or set of functions) that would allow a user to determine if a pointer is valid system-allocated memory. Perhaps Microsoft has not made these functions public. If Microsoft has not provided such an API, I can only presume that it was for an intentional and specific reason. Would providing such a hook into the system prose a significant threat to system security? Situation Report Although knowing whether a memory pointer is valid could be useful in many scenarios, this is my particular situation: I am writing a driver for a new piece of hardware that is to replace an existing piece of hardware that connects to the PC via USB. My mandate is to write the new driver such that calls to the existing API for the current driver will continue to work in the PC applications in which it is used. Thus the only required changes to existing applications is to load the appropriate driver DLL(s) at startup. The problem here is that the existing driver uses a callback to send received serial messages to the application; a pointer to allocated memory containing the message is passed from the driver to the application via the callback. It is then the responsibility of the application to call another driver API to free the memory by passing back the same pointer from the application to the driver. In this scenario the second API has no way to determine if the application has actually passed back a pointer to valid memory.

    Read the article

  • How do you delete a pointer without deleting the data the pointer points to?

    - by Faken
    I have a pointer that points to an array and another pointer referencing the same array. How do i delete any one of those pointers without killing the array such that the second undeleted pointer still works? for example: int* pointer1 = new int [1000]; int* pointer2; pointer2 = pointer1; Now i want to get rid of pointer1, how would i do it such that i can continue to access the array normaly through pointer2?

    Read the article

  • boost::function function pointer to parameters?

    - by high6
    How does boost::function take a function pointer and get parameters from it? I want wrap a function pointer so that it can be validated before being called. And it would be nice to be able to call it like boost::function is with the () operator and not having to access the function pointer member. Wrapper func; func(5); //Yes :D func.Ptr(5) //Easy to do, but not as nice looking

    Read the article

  • Detect pointer arithmetics because of LARGEADDRESSAWARE

    - by Suma
    I would like to switch my application to LARGEADDRESSAWARE. One of issues to watch for is pointer arithmetic, as pointer difference can no longer be represented as signed 32b. Is there some way how to find automatically all instances of pointer subtraction in a large C++ project? If not, is there some "least effort" manual or semi-automatic method how to achieve this?

    Read the article

  • Start a thread using a method pointer

    - by Michael
    Hi ! I'm trying to develop a thread abstraction (POSIX thread and thread from the Windows API), and I would very much like it to be able to start them with a method pointer, and not a function pointer. What I would like to do is an abstraction of thread being a class with a pure virtual method "runThread", which would be implanted in the future threaded class. I don't know yet about the Windows thread, but to start a POSIX thread, you need a function pointer, and not a method pointer. And I can't manage to find a way to associate a method with an instance so it could work as a function. I probably just can't find the keywords (and I've been searching a lot), I think it's pretty much what Boost::Bind() does, so it must exist. Can you help me ?

    Read the article

  • Doubt on pointer conversion

    - by Simone
    Suppose we have the following code: #include <iostream> struct A { virtual void f() { std::cout << "A::f()" << std::endl; } }; struct B: A { void f() { std::cout << "B::f()" << std::endl; } }; void to_A(void* voidp) { A* aptr = static_cast<A*>(voidp); aptr->f(); } void to_B(void* voidp) { B* bptr2 = static_cast<B*>(voidp); bptr2->f(); } int main() { B* bptr = new B; void* voidp = bptr; to_A(voidp); // prints B::f() to_B(voidp); // prints B::f() } is this code guaranteed to always work as in the code comments or is it UB? AFAIK it should be ok, but I'd like to be reassured.

    Read the article

  • [C++] Start a thread using a method pointer

    - by Michael
    Hi ! I'm trying to develop a thread abstraction (POSIX thread and thread from the Windows API), and I would very much like it to be able to start them with a method pointer, and not a function pointer. What I would like to do is an abstraction of thread being a class with a pure virtual method "runThread", which would be implanted in the future threaded class. I don't know yet about the Windows thread, but to start a POSIX thread, you need a function pointer, and not a method pointer. And I can't manage to find a way to associate a method with an instance so it could work as a function. I probably just can't find the keywords (and I've been searching a lot), I think it's pretty much what Boost::Bind() does, so it must exist. Can you help me ?

    Read the article

  • command&pointer&malloc [closed]

    - by gcc
    input 23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x //according to input,i should create int pointer arrays. pointer arrays starting from 1 (that is initial arrays is arrays[1].when program sees n ,it must be jumb to arrays 2 expected output arrays[1] 3 4 5 42 arrays[2] 23 0 9 9 arrays[5] 3 9 9 x is stopper n is comman to create new pointer array i am new in this site anyone help me how can i write

    Read the article

  • When is "this" pointer initialized in C++?

    - by skydoor
    Hi I have a question about this pointer, when an object is constructed, when it is initialized? Which means, when can I use it? The virtual table is constructed in the constructor, is the same with this pointer? For example, I have a code like this. The output is 8. Does it mean that before the constructor is entered, this pointer is already initialized? class A{ public: A() { cout<<sizeof(*this);} int i; int *p; }; int main() { A a; } If it is true, what else would happen before the constructor is entered? If it is not true, when is the this pointer initialized?

    Read the article

  • Workstation 7 build 203739 - Capture Movie Mouse Pointer Not Visible

    - by BMIVM
    Hi, I have noticed that whenever I create a Capture Movie, the movie is fine but the mouse pointer is not visible at all. The clicks are on buttons file menus are executed but is hard for a viewer of the capturre movie session to follow the recording smoothly. This was not a problem in previous versions of WorkStation. Is this a bug or is there a setting I can set to see the mouse pointer? Note: VM Tools are installed, Host is Vista Ultimate Edtion SP1, x64 and the guest is a Win XP SP2. Thanks in advance for your help.

    Read the article

  • VMware Workstation 7 build 203739 - Capture Movie Mouse Pointer Not Visible

    - by BMIVM
    Hi, I have noticed that whenever I create a Capture Movie, the movie is fine but the mouse pointer is not visible at all. The clicks are on buttons file menus are executed but is hard for a viewer of the capturre movie session to follow the recording smoothly. This was not a problem in previous versions of WorkStation. Is this a bug or is there a setting I can set to see the mouse pointer? Note: VM Tools are installed, Host is Vista Ultimate Edtion SP1, x64 and the guest is a Win XP SP2. Thanks in advance for your help.

    Read the article

  • static void classes

    - by ivor
    Hello, I'm tidying up some of my code with the correct scope on some methods and attributes (I have two classes and at the moment I have a number which I just declared as public to get working, but I feel I should look into this and make private where possible, for better practice) When working in eclipse it's suggested on one method, when i change it private from public, that I can fix it by dropping off the scope so the method just says "static void" instead of public/private static void. Is this a better scenario to have nothing, rather than private or public - or is the default scope equivelant to public anyway ? Thanks

    Read the article

  • How to make Spring accept non-void setters?

    - by Chris
    Hi, I have an API which I am turning into an internal DSL. As such, most methods in my PoJos return a reference to this so that I can chain methods together declaratively as such (syntactic sugar). myComponent .setID("MyId") .setProperty("One","1") .setProperty("Two","2") .setAssociation(anotherComponent) .execute(); My API does not depend on Spring but I wish to make it 'Spring-Friendly' by being PoJo friendly with zero argument constructors, getters and setters. The problem is that Spring seems to not detect my setter methods when I have a non-void return type. The return type of this is very convenient when chaining together my commands so I don't want to destroy my programmatic API just be to compatible with Spring injection. Is there a setting in Spring to allow me to use non-void setters? Chris

    Read the article

  • [Objective-C] Primitive question, (void) init method.

    - by user354289
    Hi, I have a question in Objective-C. I'm using init method Apple recommended style. - (id)initMyClass: (int)a { if (self = [super init]) { // a... } return self; } Init method returns own object pointer. Then, if the object will not be refered from any objects, can empty return method(void) be better? - (void)initMyClass: (int)a { if ([super init] != nil) { // a... } } I want to know about that, if init method doesn't return self, what problem will occur?

    Read the article

  • Can I void all JavaScript calls to $

    - by alex
    I need some scripts inside an existing site's scripts.js. This site has been online for ages, and I can not touch the scripts file. I am including it standardly in another page. There are numerous jQuery calls in the scripts file. The place I include it does not have jQuery. I want to void all $() type things. I tried this... $ = function() { }; before I included scripts.js and it didn't seem to work. I am still getting errors like $(document) is undefined Is there a way to void all these jQuery calls? Thanks

    Read the article

  • Using (void)awakeFromNib

    - by MN
    I am trying to run an action when the application starts. The action checkAtStart is supposed to display an alert if there is no text in field1 and hide startView if there is text in field1. checkAtStart works fine if assigned to a button, but when I try to run it using (void)awakeFromNib, the alert will display no matter what and startView will never hide. Its probably something really simple that I'm forgetting. Any help is appreciated! Here is my code: - (void)awakeFromNib { [self checkAtStart:self]; } - (IBAction)checkAtStart:(id)sender { if (field1.text == nil || [field1.text isEqualToString:@""]) { NSString *msg = nil; msg = nil; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message" message:@"Test Message" delegate:self cancelButtonTitle:@"Close" otherButtonTitles: nil]; [alert show]; [alert release]; [msg release]; } else { startView.hidden = YES; } }

    Read the article

  • Why is Window.open()'s return type void ?

    - by Salvin Francis
    Doing something like this is perfectly permissible in javascript: var newWindow = window.open(...) However, this does not work in the senario of GWT (I am using 1.5 I dont know about later versions), Window window = Window.open("", "", ""); Throws me a compile time error that the open is a method with a return type as void. Why should it be void ? What if i want to close my popup from the main Window ? how do I get its handle ? I will have to resort to native javascript no doubt but i was just curious so as to why this is so...

    Read the article

  • Find a base case for a recursive void method

    - by Evan S
    I am doing homework. I would like to build a base case for a recursion where ordering given numbers (list2) in ascending order. Purpose of writing this codes is that when all numbers are in ascending order then should stop calling a method called ascending(list2, list1); and all values in list2 should be shipped to list1. For instance, list2 = 6,5,4,3,2,1 then list2 becomes empty and list1 should be 1,2,3,4,5,6. I am trying to compare result with previous one and if matches then stop. But I can't find the base case to stop it. In addition, Both ascending() and fixedPoint() are void method. Anybody has idea? lol Took me 3 days... When I run my code then 6,5,4,3,2,1 5,6,4,3,2,1 4,5,6,3,2,1 3,4,5,6,2,1 2,3,4,5,6,1 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 1,2,3,4,5,6 infinite............. public class Flipper { public static void main(String[] args) { Flipper aFlipper = new Flipper(); List<Integer> content = Arrays.asList(6,5,4,3,2,1); ArrayList<Integer> l1 = new ArrayList<Integer>(content); ArrayList<Integer> l2 = new ArrayList<Integer>(); // empty list aFlipper.fixedPoint(l2,l1); System.out.println("fix l1 is "+l1); System.out.println("fix l2 is "+l2); } public void fixedPoint(ArrayList<Integer> list1, ArrayList<Integer> list2) { // data is in list2 ArrayList<Integer> temp1 = new ArrayList<Integer>(); // empty list if (temp1.equals(list2)) { System.out.println("found!!!"); } else { ascending(list2, list1); // data, null temp1 = list1; // store processed value System.out.println("st list1 is "+list1); System.out.println("st list2 is "+list2); } fixedPoint(list2, list1); // null, processed data }

    Read the article

  • What's void *userData exactly?

    - by mystify
    In a C function declaration, I have seen this parameter definition: void *userData so, what exactly is that? My guess: the void says it can be anything arbitrary, or even nothing. Almost similar to id of objective-c. It just allows to pass in whatever data structure you like. The star in front of userData says, that the argument must be passed in by reference. So when using this stuff in the function body, typically it must be casted and dereferenced. So if I pass in an pointer to SomeClass instance, I would get that like this: SomeClass *myObj = (SomeClass*)userData; In the case I had nothing special to pass along, I would provide NULL as argument. Are my assumptions correct? Or did I get something wrong?

    Read the article

  • Treat a void function as a value

    - by Brendan Long
    I'm writing some terrible, terrible code, and I need a way to put a free() in the middle of a statement. The actual code is: int main(){ return printf("%s", isPalindrome(fgets(malloc(1000), 1000, stdin))?"Yes!\n":"No!\n") >= 0; // leak 1000 bytes of memory } I was using alloca(), but I can't be sure that will actually work on my target computer. My problem is that free returns void, so my code has this error message: error: void value not ignored as it ought to be The obvious idea I had was: int myfree(char *p){ free(p); return 0; } Which is nice in that it makes the code even more unreadable, but I'd prefer not to add another function. I also briefly tried treating free() as a function pointer, but I don't know if that would work, and I don't know enough about C to do it properly. Note: I know this is a terrible idea. Don't try this at home kids.

    Read the article

  • JUnit for Functions with Void Return Values

    - by RobotNerd
    I've been working on a Java application where I have to use JUnit for testing. I am learning it as I go. So far I find it to be useful, especially when used in conjunction with the Eclipse JUnit plugin. After playing around a bit, I developed a consistent method for building my unit tests for functions with no return values. I wanted to share it here and ask others to comment. Do you have any suggested improvements or alternative ways to accomplish the same goal? Common Return Values First, there's an enumeration which is used to store values representing test outcomes. public enum UnitTestReturnValues { noException, unexpectedException // etc... } Generalized Test Let's say a unit test is being written for: public class SomeClass { public void targetFunction (int x, int y) { // ... } } The JUnit test class would be created: import junit.framework.TestCase; public class TestSomeClass extends TestCase { // ... } Within this class, I create a function which is used for every call to the target function being tested. It catches all exceptions and returns a message based on the outcome. For example: public class TestSomeClass extends TestCase { private UnitTestReturnValues callTargetFunction (int x, int y) { UnitTestReturnValues outcome = UnitTestReturnValues.noException; SomeClass testObj = new SomeClass (); try { testObj.targetFunction (x, y); } catch (Exception e) { UnitTestReturnValues.unexpectedException; } return outcome; } } JUnit Tests Functions called by JUnit begin with a lowercase "test" in the function name, and they fail at the first failed assertion. To run multiple tests on the targetFunction above, it would be written as: public class TestSomeClass extends TestCase { public void testTargetFunctionNegatives () { assertEquals ( callTargetFunction (-1, -1), UnitTestReturnValues.noException); } public void testTargetFunctionZeros () { assertEquals ( callTargetFunction (0, 0), UnitTestReturnValues.noException); } // and so on... } Please let me know if you have any suggestions or improvements. Keep in mind that I am in the process of learning how to use JUnit, so I'm sure there are existing tools available that might make this process easier. Thanks!

    Read the article

  • Referring to this pointer in a static assert?

    - by Tyson Jacobs
    Is it possible to write a static assert referring to the 'this' pointer? I do not have c++11 available, and BOOST_STATIC_ASSERT doesn't work. struct blah { void func() {BOOST_STATIC_ASSERT(sizeof(*this));} }; Produces: error C2355: 'this' : can only be referenced inside non-static member functions error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' In MSVC 2008. Motivation: #define CLASS_USES_SMALL_POOL() \ void __small_pool_check() {BOOST_STATIC_ASSERT(sizeof(*this) < SMALL_MALLOC_SIZE;} \ void* operator new(size_t) {return SmallMalloc();} \ void operator delete(void* p) {SmallFree(p);}

    Read the article

  • Need alternative to Accessibility's "Locate Pointer" to visually highlight the mouse.

    - by fred.bear
    Update: See end of quetion: A black-on-white cross-hair/I-bar mouse-pointer is soemtimes hard foe me to spot in amongst black-on-white text. I've tried "Accessibility / Mouse Accessibility / Locate Pointer" .. which will: Show pointer position when Control is presssed It works (to a point), but it does have a notable problem, which renders it inpractical. It has the uncanny side-effect of disallowing all Control key navigation while editing a file/dir name in Nautilus (F2).. Just touching the Control key drops it out of edit mode, which means I can't keyboard paste, move-L/R word etc... So, I'm looking for an alternative. I've tried Compiz's Water Effect, but I need something which is sharper, faster, and localized to the pointer. Compiz's Show Mouse (with fire) is no suitable. I'm really lookingf for an analog of "Accessibility / Locate Pointer": * ie. I hit Control (only).. and it blips a quick visual pulse. UPDATE: I've just realized why I can't find my mouse so often! ... It's because it is isn't there !!! ... Two apps I use a lot, Gedit and Konsole (KDE Terminal; it renders unicode better), ... dissolve the mouse-pointer to invisible after the first key is typed ... and Konsole does it after a few seconds of idle-time... like a video-player option: "hide the mouse".. Well I don't use the mouse much, and I thought it was juse my eyesight (which does rely a lot on Compiz's zoom)... I discovered it when I installed a "novelty" app, called Geyes from gnome-applets ("A goofy set of eyes for the GNOME panel. They follow your mouse.") ... It could follow the mouse better than me! :)

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >