Search Results

Search found 3592 results on 144 pages for 'pointer'.

Page 118/144 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • Delphi Pascal / Windows API - Small problem with SetFilePointerEx and parameter FILE_END

    - by SuicideClutchX2
    I know I am about to be slapped by at least one person who was helping me with this API. Alright I have been able to use SetFilePointerEx just fine, when setting the position only. SetFilePointerEx(PD,512,@PositionVar,FILE_BEGIN); SetFilePointerEx(PD,0,@PositionVar,FILE_CURRENT); Both work, I can set positions and even check my current one. But when I set FILE_END as per the documentation no matter what the second parameter is and whether or not i provide a pointer for the third parameter it fails even on a valid handle that many other operations are able to use without fail. For Example: SetFailed := SetFilePointerEx(PD,0,@PositionVar,FILE_END); SetFailed := SetFilePointerEx(PD,0,nil,FILE_END); Whatever I put it fails. I am working with a handle to a physical disk and it most definitely has an end. SetFilePointer works just fine its just a little more trouble than I would like. Its not the end of the world, but whats happening.

    Read the article

  • Set scaleX property on a Sprite without altering the child inside

    - by grammar
    Is this possible? My site is set up with next and prev buttons on the right and left sides respectively, and as you roll over either of the hit areas around the buttons a Sprite fades in which contains a TextField that describes the next page. Said Sprite calls the StartDrag() method, so it follows the mouse within the bounds, which is all fine and dandy on the left side of the page. Adobe, however, seems to have forgotten to put a way to dynamically alter the registration point of a Sprite, MC, whatever else, so when you roll over the right side of the page, the sprite is displayed from the top left and is mostly off the stage. Trying to hack this problem I have tried numerous things ( classes written by others, other hacks) and the best that I have found is to use the scaleX method on the Sprite, changing the scale to -1. This, of course, makes the Sprite seem like it's reflected from its normal point, which means all its children show up backwards. Is there anyway I can use this hack without it altering the text? OR Does anyone know a different way to go about displaying a Sprite from another corner? Any way to make a Sprite fade in and follow the mouse on the LEFT HAND side of the mouse pointer? Thank you very much in advance. Here is a snippet to give an idea of what's happening: naxtPage.labelBG.scaleX = -1; nextPage.labelBG.startDrag( true, nextHitRect ); nextPage.labelBG.x = nextPage.labelBG.parent.mouseX; nextPage.labelBG.y = nextPage.labelBG.parent.mouseY; Cheers

    Read the article

  • Passing Derived Class Instances as void* to Generic Callbacks in C++

    - by Matthew Iselin
    This is a bit of an involved problem, so I'll do the best I can to explain what's going on. If I miss something, please tell me so I can clarify. We have a callback system where on one side a module or application provides a "Service" and clients can perform actions with this Service (A very rudimentary IPC, basically). For future reference let's say we have some definitions like so: typedef int (*callback)(void*); // This is NOT in our code, but makes explaining easier. installCallback(string serviceName, callback cb); // Really handled by a proper management system sendMessage(string serviceName, void* arg); // arg = value to pass to callback This works fine for basic types such as structs or builtins. We have an MI structure a bit like this: Device <- Disk <- MyDiskProvider class Disk : public virtual Device class MyDiskProvider : public Disk The provider may be anything from a hardware driver to a bit of glue that handles disk images. The point is that classes inherit Disk. We have a "service" which is to be notified of all new Disks in the system, and this is where things unravel: void diskHandler(void *p) { Disk *pDisk = reinterpret_cast<Disk*>(p); // Uh oh! // Remainder is not important } SomeDiskProvider::initialise() { // Probe hardware, whatever... // Tell the disk system we're here! sendMessage("disk-handler", reinterpret_cast<void*>(this)); // Uh oh! } The problem is, SomeDiskProvider inherits Disk, but the callback handler can't receive that type (as the callback function pointer must be generic). Could RTTI and templates help here? Any suggestions would be greatly appreciated.

    Read the article

  • String Length Evaluating Incorrectly

    - by Justin R.
    My coworker and I are debugging an issue in a WCF service he's working on where a string's length isn't being evaluated correctly. He is running this method to unit test a method in his WCF service: // Unit test method public void RemoveAppGroupTest() { string addGroup = "TestGroup"; string status = string.Empty; string message = string.Empty; appActiveDirectoryServicesClient.RemoveAppGroup("AOD", addGroup, ref status, ref message); } // Inside the WCF service [OperationBehavior(Impersonation = ImpersonationOption.Required)] public void RemoveAppGroup(string AppName, string GroupName, ref string Status, ref string Message) { string accessOnDemandDomain = "MyDomain"; RemoveAppGroupFromDomain(AppName, accessOnDemandDomain, GroupName, ref Status, ref Message); } public AppActiveDirectoryDomain(string AppName, string DomainName) { if (string.IsNullOrEmpty(AppName)) { throw new ArgumentNullException("AppName", "You must specify an application name"); } } We tried to step into the .NET source code to see what value string.IsNullOrEmpty was receiving, but the IDE printed this message when we attempted to evaluate the variable: 'Cannot obtain value of local or argument 'value' as it is not available at this instruction pointer, possibly because it has been optimized away.' (None of the projects involved have optimizations enabled). So, we decided to try explicitly setting the value of the variable inside the method itself, immediately before the length check -- but that didn't help. // Lets try this again. public AppActiveDirectoryDomain(string AppName, string DomainName) { // Explicitly set the value for testing purposes. AppName = "AOD"; if (AppName == null) { throw new ArgumentNullException("AppName", "You must specify an application name"); } if (AppName.Length == 0) { // This exception gets thrown, even though it obviously isn't a zero length string. throw new ArgumentNullException("AppName", "You must specify an application name"); } } We're really pulling our hair out on this one. Has anyone else experienced behavior like this? Any tips on debugging it?

    Read the article

  • Is this a safe/valid hash method implementation?

    - by Sean
    I have a set of classes to represent some objects loaded from a database. There are a couple variations of these objects, so I have a common base class and two subclasses to represent the differences. One of the key fields they have in common is an id field. Unfortunately, the id of an object is not unique across all variations, but within a single variation. What I mean is, a single object of type A could have an id between, say, 0 and 1,000,000. An object of type B could have an id between, 25,000 and 1,025,000. This means there's some overlap of id numbers. The objects are just variations of the same kind of thing, though, so I want to think of them as such in my code. (They were assigned ids from different sets for legacy reasons.) So I have classes like this: @class BaseClass @class TypeAClass : BaseClass @class TypeBClass : BaseClass BaseClass has a method (NSNumber *)objectId. However instances of TypeA and TypeB could have overlapping ids as discussed above, so when it comes to equality and putting these into sets, I cannot just use the id alone to check it. The unique key of these instances is, essentially, (class + objectId). So I figured that I could do this by making the following hash function on the BaseClass: -(NSUInteger)hash { return (NSUInteger)[self class] ^ [self.objectId hash]; } I also implemented isEqual like so: - (BOOL)isEqual:(id)object { return (self == object) || ([object class] == [self class] && [self.objectId isEqual:[object objectId]]); } This seems to be working, but I guess I'm just asking here to make sure I'm not overlooking something - especially with the generation of the hash by using the class pointer in that way. Is this safe or is there a better way to do this?

    Read the article

  • Send Click Message to another application process

    - by Nazar
    Hi Guys I have a scenario, i need to send click events to an independent application. I started that application with the following code. private Process app; app = new Process(); app.StartInfo.FileName = app_path; app.StartInfo.WorkingDirectory = dir_path; app.Start(); Now i want to send Mouse click message to that applicaiton, I have specific coordinates in relative to application window. How can i do it using Windows Messaging or any other technique. I used [DllImport("user32.dll")] private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo); It works well but cause the pointer to move as well. So not fit for my need. Then i use. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); It works well for minimize maximize, but do not work for mouse events. The codes for mousevents i am using are, WM_LBUTTONDOWN = 0x201, //Left mousebutton down WM_LBUTTONUP = 0x202, //Left mousebutton up WM_LBUTTONDBLCLK = 0x203, //Left mousebutton doubleclick WM_RBUTTONDOWN = 0x204, //Right mousebutton down WM_RBUTTONUP = 0x205, //Right mousebutton up WM_RBUTTONDBLCLK = 0x206, //Right mousebutton do Thanks for the help in advance, and waiting for feedback.

    Read the article

  • Jquery draggable not working in chrome/safari

    - by jbatson
    I have created a page that uses ajax calls to load product images. The jquery code for drag, drop and clone would not work when in the index.php page so I moved it to the page that gets called to request the products as each product has drag, drop code created for it. Works fine in FF, even IE but not in Safari or Chrome. Below is the jquery code in load_products.php that gets created when the ajax call is made to load the products. http://tandyleatherfactory.net/ Anyone have any idea why wouldn't work in Safari? $(function() {$("#concho_4_2").draggable({ helper: 'clone', cursor: 'pointer', zIndex: '1001', stop: function(event, ui) { offsetElement = $(ui.helper).offset(); offNewContainer = $('#belts').offset(); var dataId = $(ui.helper).attr('id'); ajaxRequest('http://tandyleatherfactory.net/includes/ahah/add_product.php', 'product=4', '#conchos'); var randomnumber = Math.floor(Math.random()*1000000); var newId = 'concho_4_2_'+randomnumber; $(ui.helper).clone(true).removeAttr('id').attr('id',newId).css("left", offsetElement.left-offNewContainer.left-10).css("top", offsetElement.top-offNewContainer.top-10).appendTo('#belts'); $('#'+newId).draggable(); } });

    Read the article

  • NSCollectionView: Can the same object not be in the array more than once or is this a bug?

    - by Sean
    I may be doing this all wrong, but I thought I was on the right track until I hit this little snag. Basically I was putting together a toy using NSCollectionView and trying to understand how to hook that all up using IB. I have a button which will add a couple of strings to the NSArrayController: The first time I press this button, my strings appear in the collection view as expected: The second time I press the button, the views scroll down and room is made - but the items don't appear to get added. I just see blank space: The button is implemented as follows (controller is a pointer to the NSArrayController I added in IB): - (IBAction)addStuff:(id)control { [controller addObjects:[NSArray arrayWithObjects:@"String 1",@"String 2",@"String 3",nil]]; } I'm not sure what I'm doing wrong. Rather than try to explain all the connections/binds/etc, if you need more info, I'd be grateful if you could just take a quick look at the toy project itself. UPDATE: After more experimentation as suggested by James Williams, it seems the problem stems from having multiple objects with the same memory address in the array. This confuses either NSArrayController or NSCollectionView (not sure which). Changing my addStuff: to this resulted in the behavior I originally expected: [controller addObjects:[NSArray arrayWithObjects:[NSMutableString stringWithString:@"String 1"],[NSMutableString stringWithString:@"String 2"],[NSMutableString stringWithString:@"String 3"],nil]]; So the question now, I guess, is if this is a bug I should report to Apple or if this is intended/documented behavior and I just missed it?

    Read the article

  • List local printers

    - by vladimir
    hi all, i am using this routine to list the local printers installed on on a machine... var p: pointer; hpi: _PRINTER_INFO_2A; hGlobal: cardinal; dwNeeded, dwReturned: DWORD; bFlag: boolean; i: dword; begin p := nil; EnumPrinters(PRINTER_ENUM_LOCAL, nil, 2, p, 0, dwNeeded, dwReturned); if (dwNeeded = 0) then exit; GetMem(p,dwNeeded); if (p = nil) then exit; bFlag := EnumPrinters(PRINTER_ENUM_LOCAL, nil, 2, p, dwneeded, dwNeeded, dwReturned); if (not bFlag) then exit; CbLblPrinterPath.Properties.Items.Clear; for i := 0 to dwReturned - 1 do begin CbLblPrinterPath.Properties.Items.Add(TPrinterInfos(p^)[i].pPrinterName); end; FreeMem(p); TPrinterInfos(p^)[i].pPrinterName returns a 'P' for printer name. i have a PdfCreator installed as a printer. TPrinterInfos is an array of _PRINTER_INFO_2A. how can i fix this?

    Read the article

  • css style remains after click

    - by rod
    Hi All, I have a simple test page with a single styled button. I'm using a:hover when you hover over the button. However, when you click the button the a:hover style remains until I click on something else. How would I fix this and why is this happening? Thanks, rod. <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <% using (Ajax.BeginForm(new AjaxOptions { })) { %> <div id="detailActions"> <a href="#">Delete User</a> </div> <% } %> </asp:Content> My CSS: #detailActions { margin-bottom: 7px; padding: 3px 0px 5px 0px; } #detailActions { padding: 1px 7px 1px 7px; margin: 0px 5px 0px 0px; border: solid 1px gray; background-color: #ADD8E6; cursor: pointer; width: auto !important; font-weight: bold; text-decoration: none; color: #003366; font-size: 1.2em; } #detailActions a:hover, #detailActions a:active, #detailActions a:focus { color: White; background-color: #00008B; }

    Read the article

  • Using Interface Builder efficiently

    - by Aaron Wetzler
    I am new to iPhone and objective c. I have spent hours and hours and hours reading documents and trying to understand how things work. I have RTFM or at least am in the process. My main problem is that I want to understand how to specify where an event gets passed to and the only way I have been able to do it is by specifying delegates but I am certain there is an easier/quicker way in IB. So, an example. Lets say I have 20 different views and view controllers and one MyAppDelegate. I want to be able to build all of these different Xib files in IB and add however many buttons and text fields and whatever and then specify that they all produce some event in the MyAppDelegate object. To do this I added a MyAppDelegate object in each view controller in IB's list view. Then I created an IBAction method in MyAppDelegate in XCode and went back to IB and linked all of the events to the MyAppDelegate object in each Xib file. However when I tried running it it just crashed with a bad read exception. My guess is that each Xib file is putting a MyAppDelegate object pointer that has nothing to do with the eventual MyAppDelegate adress that will actually be created at runtime. So my question is...how can I do this?!!!

    Read the article

  • Drawing an image is completely out

    - by ct2k7
    Hi I'm using this code below to let a user "draw" their signature on a UIView component on my app: UIGraphicsBeginImageContext(signature.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, signature.frame.size.width, signature.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext() The issue I am having is that the drawing is not only is the drawing not in line with the pointer when in use in the simulator, the image is going outside of the designated UIView compontent and is getting smaller/out of focus the more I draw, as you can see in this image: And after a few lines, showing the boundaries of the exact are of where I can draw: Any ideas on what's happening here? lastPoint.y is defined as: lastPoint.y -= 20; Any ideas on what on earth is happening here?

    Read the article

  • Mulit-dimensional array edge/border conditions

    - by kirbuchi
    Hi, I'm iterating over a 3 dimensional array (which is an image with 3 values for each pixel) to apply a 3x3 filter to each pixel as follows: //For each value on the image for (i=0;i<3*width*height;i++){ //For each filter value for (j=0;j<9;j++){ if (notOutsideEdgesCondition){ *(**(outArray)+i)+= *(**(pixelArray)+i-1+(j%3)) * (*(filter+j)); } } } I'm using pointer arithmetic because if I used array notation I'd have 4 loops and I'm trying to have the least possible number of loops. My problem is my notOutsideEdgesCondition is getting quite out of hands because I have to consider 8 border cases. I have the following handled conditions Left Column: ((i%width)==0) && (j%3==0) Right Column: ((i-1)%width ==0) && (i>1) && (j%3==2) Upper Row: (i<width) && (j<2) Lower Row: (i>(width*height-width)) && (j>5) and still have to consider the 4 corner cases which will have longer expressions. At this point I've stopped and asked myself if this is the best way to go because If I have a 5 line long conditional evaluation it'll not only be truly painful to debug but will slow the inner loop. That's why I come to you to ask if there's a known algorithm to handle this cases or if there's a better approach for my problem. Thanks a lot.

    Read the article

  • Implementation/interface inheritance design question.

    - by Neil G
    I would like to get the stackoverflow community's opinion on the following three design patterns. The first is implementation inheritance; the second is interface inheritance; the third is a middle ground. My specific question is: Which is best? implementation inheritance: class Base { X x() const = 0; void UpdateX(A a) { y_ = g(a); } Y y_; } class Derived: Base { X x() const { return f(y_); } } interface inheritance: class Base { X x() const = 0; void UpdateX(A a) = 0; } class Derived: Base { X x() const { return x_; } void UpdateX(A a) { x_ = f(g(a)); } X x_; } middle ground: class Base { X x() const { return x_; } void UpdateX(A a) = 0; X x_; } class Derived: Base { void UpdateX(A a) { x_ = f(g(a)); } } I know that many people prefer interface inheritance to implementation inheritance. However, the advantage of the latter is that with a pointer to Base, x() can be inlined and the address of x_ can be statically calculated.

    Read the article

  • std::string insert method has ambiguous overloads?

    - by sdg
    Environment: VS2005 C++ using STLPort 5.1.4. Compiling the following code snippet: std::string copied = "asdf"; char ch = 's'; copied.insert(0,1,ch); I receive an error: Error 1 error C2668: 'stlpx_std::basic_string<_CharT,_Traits,_Alloc>::insert' : ambiguous call to overloaded function It appears that the problem is the insert method call on the string object. The two defined overloads are void insert ( iterator p, size_t n, char c ); string& insert ( size_t pos1, size_t n, char c ); But given that STLPort uses a simple char* as its iterator, the literal zero in the insert method in my code is ambiguous. So while I can easily overcome the problem by hinting such as copied.insert(size_t(0),1,ch); My question is: is this overloading and possible ambiguity intentional in the specification? Or more likely an unintended side-effect of the specific STLPort implementation? (Note that the Microsoft-supplied STL does not have this problem as it has a class for the iterator, instead of a naked pointer)

    Read the article

  • What is a NULL value

    - by Adi
    I am wondering , what exactly is stored in the memory when we say a particular variable pointer to be NULL. suppose I have a structure, say typdef struct MEM_LIST MEM_INSTANCE; struct MEM_LIST { char *start_addr; int size; MEM_INSTANCE *next; }; MEM_INSTANCE *front; front = (MEM_INSTANCE*)malloc(sizeof(MEM_INSTANCE*)); -1) If I make front=NULL. What will be the value which actually gets stored in the different fields of the front, say front-size ,front-start_addr. Is it 0 or something else. I have limited knowledge in this NULL thing. -2) If I do a free(front); It frees the memory which is pointed out by front. So what exactly free means here, does it make it NULL or make it all 0. -3) What can be a good strategy to deal with initialization of pointers and freeing them . Thanks in advance

    Read the article

  • MySQL Ratings From Two Tables

    - by DirtyBirdNJ
    I am using MySQL and PHP to build a data layer for a flash game. Retrieving lists of levels is pretty easy, but I've hit a roadblock in trying to fetch the level's average rating along with it's pointer information. Here is an example data set: levels Table: level_id | level_name 1 | Some Level 2 | Second Level 3 | Third Level ratings Table: rating_id | level_id | rating_value 1 | 1 | 3 2 | 1 | 4 3 | 1 | 1 4 | 2 | 3 5 | 2 | 4 6 | 2 | 1 7 | 3 | 3 8 | 3 | 4 9 | 3 | 1 I know this requires a join, but I cannot figure out how to get the average rating value based on the level_id when I request a list of levels. This is what I'm trying to do: SELECT levels.level_id, AVG(ratings.level_rating WHERE levels.level_id = ratings.level_id) FROM levels I know my SQL is flawed there, but I can't figure out how to get this concept across. The only thing I can get to work is returning a single average from the entire ratings table, which is not very useful. Ideal Output from the above conceptually valid but syntactically awry query would be: level_id | level_rating 1| 3.34 2| 1.00 3| 4.54 My main issue is I can't figure out how to use the level_id of each response row before the query has been returned. It's like I want to use a placeholder... or an alias... I really don't know and it's very frustrating. The solution I have in place now is an EPIC band-aid and will only cause me problems long term... please help!

    Read the article

  • Mac OS X and static boost libs -> std::string fail

    - by Ionic
    Hi all, I'm experiencing some very weird problems with static boost libraries under Mac OS X 10.6.6. The error message is main(78485) malloc: *** error for object 0x1000e0b20: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug [1] 78485 abort (core dumped) and a tiny bit of example code which will trigger this problem: #define BOOST_FILESYSTEM_VERSION 3 #include <boost/filesystem.hpp> #include <iostream> int main (int argc, char **argv) { std::cout << boost::filesystem::current_path ().string () << '\n'; } This problem always occurs when linking the static boost libraries into the binary. Linking dynamically will work fine, though. I've seen various reports for quite a similar OS X bug with GCC 4.2 and the _GLIBCXX_DEBUG macro set, but this one seems even more generic, as I'm neither using XCode, nor setting the macro (even undefining it does not help. I tried it just to make sure it's really not related to this problem.) Does anybody have any pointers to why this is happening or even maybe a solution (rather than using the dynamic library workaround)? Best regards, Mihai

    Read the article

  • Working with complex objects in Prevayler commands

    - by alexantd
    The demos included in the Prevayler distribution show how to pass in a couple strings (or something simple like that) into a command constructor in order to create or update an object. The problem is that I have an object called MyObject that has a lot of fields. If I had to pass all of them into the CreateMyObject command manually, it would be a pain. So an alternative I thought of is to pass my business object itself into the command, but to hang onto a clone of it (keeping in mind that I can't store the BO directly in the command). Of course after executing this command, I would need to make sure to dispose of the original copy that I passed in. public class CreateMyObject implements TransactionWithQuery { private MyObject object; public CreateMyObject(MyObject business_obj) { this.object = (MyObject) business_obj.clone(); } public Object executeAndQuery(...) throws Exception { ... } } The Prevayler wiki says: Transactions can't carry direct object references (pointers) to business objects. This has become known as the baptism problem because it's a common beginner pitfall. Direct object references don't work because once a transaction has been serialized to the journal and then deserialized for execution its object references no longer refer to the intended objects - - any objects they may have referred to at first will have been copied by the serialization process! Therefore, a transaction must carry some kind of string or numeric identifiers for any objects it wants to refer to, and it must look up the objects when it is executed. I think by cloning the passed-in object I will be getting around the "direct object pointer" problem, but I still don't know whether or not this is a good idea...

    Read the article

  • how to handle onclick event of button inside popup window in android

    - by henna
    In my application i have a button initially on the screen and in onclick of the button ,popup window should open. In the popup window i have an imagebutton , now on click of this button i want to start an activity. The popup window opens but i dont understand how to handle the onclick of the imagebtn inside popup window. In main.xml i have a button and in popup_example.xml i have an imagebutton. Hi my Java code is as follows: final LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final Button b=(Button)findViewById(R.id.btn); b.setOnClickListener(new OnClickListener() { public void onClick(View v) { PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup_example,(ViewGroup)findViewById(R.layout.main))); pw.showAtLocation(v, Gravity.LEFT,0,0); pw.update(8,-70,150,270); //if onclick written here, it gives null pointer exception. ImageButton img=(ImageButton)findViewById(R.id.home); img.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent..... } }); //if onclick is written here it gives runtime exception. }); and i have two xml layouts.........1)main.xml 2)popup_example.xml main.xml popup_example.xml <ImageButton android:id="@+id/home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="true" android:src="@drawable/vitalss" android:layout_weight="1" android:background="#8E2323" />

    Read the article

  • va_arg with pointers

    - by Yktula
    I want to initialize a linked list with pointer arguments like so: /* * Initialize a linked list using variadic arguments * Returns the number of structures initialized */ int init_structures(struct structure *first, ...) { struct structure *s; unsigned int count = 0; va_list va; va_start(va, first); for (s = first; s != NULL; s = va_arg(va, (struct structure *))) { if ((s = malloc(sizeof(struct structure))) == NULL) { perror("malloc"); exit(EXIT_FAILURE); } count++; } va_end(va); return count; } The problem is that clang errors type name requires a specifier or qualifier at va_arg(va, (struct structure *)), and says that the type specifier defaults to int. It also notes instantiated form at (struct structure *) and struct structure *. This, what seems to be getting assigned to s is int (struct structure *). It compiles fine when parentheses are removed from (struct structure *), but the structures that are supposed to be initialized are inaccessible. Why is int assumed when parentheses are around the type argument passed to va_arg? How can I fix this?

    Read the article

  • Using same onmouseover function for multiple objects

    - by phpscriptcoder
    I'm creating a building game in JavaScript and PHP that involves a grid. Each square in the grid is a div, with an own onmouseover and onmousedown function: for(x=0; x < width; x++) { for(y=0; y < height; y++) { var div = document.createElement("div"); //... div.onmouseclick = function() {blockClick(x, y)} div.onmouseover = function() {blockMouseover(x, y)} game.appendChild(div); } } But, all of the squares seem to have the x and y of the last square that was added. I can sort of see why this is happening - it is making a pointer to x and y instead of cloning the variables - but how could I fix it? I even tried for(x=0; x < width; x++) { for(y=0; y < height; y++) { var div = document.createElement("div"); var myX = x; var myY = y; div.onmouseclick = function() {blockClick(myX, myY)} div.onmouseover = function() {blockMouseover(myX, myY)} game.appendChild(div); } } with the same result. I was using div.setAttribute("onmouseover", ...) which worked in Firefox, but not IE. Thanks!

    Read the article

  • invasive vs non-invasive ref-counted pointers in C++

    - by anon
    For the past few years, I've generally accepted that if I am going to use ref-counted smart pointers invasive smart pointers is the way to go -- However, I'm starting to like non-invasive smart pointers due to the following: I only use smart pointers (so no Foo* lying around, only Ptr) I'm starting to build custom allocators for each class. (So Foo would overload operator new). Now, if Foo has a list of all Ptr (as it easily can with non-invasive smart pointers). Then, I can avoid memory fragmentation issues since class Foo move the objects around (and just update the corresponding Ptr). The only reason why this Foo moving objects around in non-invasive smart pointers being easier than invasive smart pointers is: In non-invasive smart pointers, there is only one pointer that points to each Foo. In invasive smart pointers, I have no idea how many objects point to each Foo. Now, the only cost of non-invasive smart pointers ... is the double indirection. [Perhaps this screws up the caches]. Does anyone have a good study of expensive this extra layer of indirection is?

    Read the article

  • How To Go About Updating Old C Code

    - by Ben313
    Hello: I have been working on some 10 year old C code at my job this week, and after implementing a few changes, I went to the boss and asked if he needed anything else done. Thats when he dropped the bomb. My next task was to go through the 7000 or so lines and understand more of the code, AND, to modularize the code somewhat. I asked him how he would like the source code modularized, and he said to start putting the old C code into c++ classes. Being a good worker, I nodded my head yes, and went back to my desk, where I sit now, wondering how in the world to take this code, and "modularize" it. Its already in 20 source files, each with its own purpose and function. in addition, there are three "main" structs. each of these stuctures has 30 plus fields, many of them being other, smaller sturcts. Its a complete mess to try to understand, but almost every single function in the program is passed a pointer to one of the structs, and uses the struct heavily. Is there any clean way for me to shoehorn this into classes? I am resolved to do it if it can be done, I just have no idea how to begin.

    Read the article

  • Is there a way to parse XML via SAX/DOM with line numbers available per node.

    - by Chris
    I already have written a DOM parser for a large XML document format that contains a number of items that can be used to automatically generate Java code. This is limited to small expressions that are then merged into a dynamically generated Java source file. So far - so good. Everything works. BUT - I wish to be able to embed the line number of the XML node where the Java code was included from (so that if the configuration contains uncompilable code, each method will have a pointer to the source XML document and the line number for ease of debugging). I don't require the line number at parse-time and I don't need to validate the XML Source Document and throw an error at a particular line number. I need to be able to access the line number for each node and attribute in my DOM or per SAX event. Any suggestions on how I might be able to achieve this? P.S. Also, I read the StAX has a method to obtain line number whilst parsing, but ideally I would like to achieve the same result with regular SAX/DOM processing in Java 4/5 rather than become a Java 6+ application or take on extra .jar files.

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >