Search Results

Search found 21563 results on 863 pages for 'context free grammar'.

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

  • Detect Applet context (am I inside an applet?)

    - by 7macaw
    Hi, I'm wondering if there's a way for a Java class to figure out if it is being used within an applet? That is, I have a library (a .jar file) that can be used by 3rd-party applications and applets. It does work within applets, but I'd like to do some things differently, depending on whether or not the library is used in an applet - like show applet-applicable errors, avoid local file I/O, etc. It would be nice if, say, Applet.getAppletContext() was static so that I could call it (and get NULL or not NULL) even if I don't have an applet instance, but alas, it isn't. Is there any other way?

    Read the article

  • Looking for a lock-free RT-safe single-reader single-writer structure

    - by moala
    Hi, I'm looking for a lock-free design conforming to these requisites: a single writer writes into a structure and a single reader reads from this structure (this structure exists already and is safe for simultaneous read/write) but at some time, the structure needs to be changed by the writer, which then initialises, switches and writes into a new structure (of the same type but with new content) and at the next time the reader reads, it switches to this new structure (if the writer multiply switches to a new lock-free structure, the reader discards these structures, ignoring their data). The structures must be reused, i.e. no heap memory allocation/free is allowed during write/read/switch operation, for RT purposes. I have currently implemented a ringbuffer containing multiple instances of these structures; but this implementation suffers from the fact that when the writer has used all the structures present in the ringbuffer, there is no more place to change from structure... But the rest of the ringbuffer contains some data which don't have to be read by the reader but can't be re-used by the writer. As a consequence, the ringbuffer does not fit this purpose. Any idea (name or pseudo-implementation) of a lock-free design? Thanks for having considered this problem.

    Read the article

  • Calling generic method in spring.net application context

    - by Bert Vandamme
    Hi, I'm trying to invoke this method in spring.net, but i'm having trouble getting the configuration right. Method: public void AddRepository(IRepository repository) where TEntity : IEntity { Repositories.Add(repository.GetType().Name, repository); } Config: <object type="Spring.Objects.Factory.Config.MethodInvokingFactoryObject, Spring.Core"> <property name="TargetObject"> <ref local="RepositoryFactory" /> </property> <property name="TargetMethod" value="AddRepository"/> <property name="Arguments"> <list> <ref object="BinaryAssetFileRepository"/> </list> </property> </object>" Is it possible to address generic methods in this way? Thx, Bert

    Read the article

  • Regexp: Replace only in specific context

    - by blinry
    In a text, I would like to replace all occurrences of $word by [$word]($word) (to create a link in Markdown), but only if it is not already in a link. Example: [$word homepage](http://w00tw00t.org) should not become [[$word]($word) homepage](http://w00tw00t.org). Thus, I need to check whether $word is somewhere between [ and ] and only replace if it's not the case. Can you think of a preg_replace command for this?

    Read the article

  • linux new/delete, malloc/free large memory blocks

    - by brian_mk
    Hi folks, We have a linux system (kubuntu 7.10) that runs a number of CORBA Server processes. The server software uses glibc libraries for memory allocation. The linux PC has 4G physical memory. Swap is disabled for speed reasons. Upon receiving a request to process data, one of the server processes allocates a large data buffer (using the standard C++ operator 'new'). The buffer size varies depening upon a number of parameters but is typically around 1.2G Bytes. It can be up to about 1.9G Bytes. When the request has completed, the buffer is released using 'delete'. This works fine for several consecutive requests that allocate buffers of the same size or if the request allocates a smaller size than the previous. The memory appears to be free'd ok - otherwise buffer allocation attempts would eventually fail after just a couple of requests. In any case, we can see the buffer memory being allocated and freed for each request using tools such as KSysGuard etc. The problem arises when a request requires a buffer larger than the previous. In this case, operator 'new' throws an exception. It's as if the memory that has been free'd from the first allocation cannot be re-allocated even though there is sufficient free physical memory available. If I kill and restart the server process after the first operation, then the second request for a larger buffer size succeeds. i.e. killing the process appears to fully release the freed memory back to the system. Can anyone offer an explanation as to what might be going on here? Could it be some kind of fragmentation or mapping table size issue? I am thinking of replacing new/delete with malloc/free and use mallopt to tune the way the memory is being released to the system. BTW - I'm not sure if it's relevant to our problem, but the server uses Pthreads that get created and destroyed on each processing request. Cheers, Brian.

    Read the article

  • Dangling pointers and double free

    - by user151410
    After some painful experiences, I understand the problem of dangling pointers and double free. I am seeking proper solutions. aStruct has a number of fields including other arrays. aStruct *A=NULL, *B = NULL; A = (aStruct*) calloc(1, sizeof(sStruct)); B = A; free_aStruct(A); ... //bunch of other code in various places. ... free_aStruct(B); Is there any way to write free_aStruct(X) so that free_aStruct(B) exists gracefully?? void free_aStruct(aStruct *X){ if (X ! = NULL){ if (X->a != NULL){free(X->a); x->a = NULL;} free(X); X = NULL; } } Doing above only sets A = NULL when free_aStruct(A); is called. B is now dangling. How can this situation be avoided / remedied? Is reference counting the only viable solution? or, are there other "defensive" free approaches, to prevent free_aStruct(B); from exploding? Thanks, Russ

    Read the article

  • CGContextShowTextAtPoint: invalid context

    - by coure06
    I want to call a method responsible for drawing text on screen after each 5 seconds. Here is my code -(void) handleTimer: (NSTimer *)timer { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, currentColor.CGColor); CGContextTranslateCTM(context, 145.0, 240.0); CGContextScaleCTM(context, 1.0, -1.0); CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman); CGContextSetCharacterSpacing(context, 1); CGContextSetTextDrawingMode(context, kCGTextFillStroke); CGContextSetRGBStrokeColor(context, 0.5,0.5,1,1); CGContextShowTextAtPoint(context, 100, 100, "01", 2); } But after 5 seconds when this method is called i am getting this error CGContextShowTextAtPoint: invalid context Another thing is how to show a thinner font?

    Read the article

  • Trial vs free with limited functionality

    - by Morten K
    Hi everyone, Not a programming question as such, but a bit more business oriented question about software product development. We have just released a small app, and is offering a free, fully functional trial which lasts for 15 days. I have the gut feeling however, that to reach any kind of penetration on the web, we'd need to offer a version which is free forever, but then has a few limitations in terms of functionality (still quite usable, but not full-throttle). For example, the Roboform browser plugin is somewhat similar in purpose to ours. Not functionality wise, but it's basically a little util that saves time and removes some repetitive-action pain. They offer a free version with limitations and then a pro version for around 30 USD. Roboform has gotten very much attention over the years, and I can't help to think that this is because they have a product which is obviously good, but also free, thus adoption becomes much higher than if they had only offered a 15 day trial. I am wondering if any of you have experience in a similar scenario? Or any thoughts on the two models? Again, I know it's not directly programming related, but it's still a question I feel best answered by a community of developers.

    Read the article

  • Binded click loses context of my Class. JS

    - by Fabiano PS
    Hi, I have this problem that I probably understand but don't know how to handle, if there is a way. I have a class simplified as this: function DrawingTable(canvas_id){ this.canvas_id = canvas_id; bind_events() function bind_events(){ $(get_canvas()).click(function(e){ var canvas = get_canvas() //works do_something_in_the_instance_who_called_click() } function get_canvas(){return document.getElementById(canvas_id)} function do_something_in_the_instance_who_called_click(){ alert(this.canvas_id) //fail! } } Because when the click() is invoked for what it looks this is not inside the instance anymore, but I need to change atributes from there.. is there a way, given that may be multiple instances? I don't really know how but the get_canvas() works :) I'm using jQuery but likely not relevant

    Read the article

  • Are there any context-sensitive code search tools?

    - by Vicky
    I have been getting very frustrated recently in dealing with a massive bulk of legacy code which I am trying to get familiar with. Say I try to search for a particular function call, I get loads of results that turn out to be completely irrelevant; some of them are easy to spot, eg a comment saying // Fixed functionality in foo() so don't need to handle this here any more But others are much harder to spot manually, because they turn out to be calls from other functions in modules that are only compiled in certain cases, or are part of a much larger block of code that is #if 0'd out in its entirety. What I'd like would be a search tool that would allow me to search for a term and give me the choice to include or exclude commented out or #if 0'd out code. Then the search results would be displayed alongside a list of #defines that are required in order for that snippet of code to be relevant. I'm working in C / C++, but other than the specific comment syntax I guess the techniques should be more generally applicable. Does such a tool exist?

    Read the article

  • C Programming: malloc and free within a loop

    - by kouei
    Hi all, I just started out with C and have very little knowledge about performance issues with malloc() and free(). My question is as such: if I were to call malloc() followed by free() in a while-loop that loops for, say, 20 times, would it run slower compared to if I were to call free() outside the loop? I am actually using the first method to allocate memory to a buffer, read a string of variable length in a file, perform some string operation, and then clear the buffer after every iteration. If my method results in a lot of overhead then I'd like to ask for a better way for me to achieve the same results. Sorry for my bad English. Thanks and regards, K

    Read the article

  • How does C free() work?

    - by slee
    #include <stdio.h> #include <stdlib.h> int * alloc() { int *p = (int *)calloc(5,4); printf("%d\n",p); return p; } int main() { int *p = alloc(); free(p); printf("%d\n",p); p[0] = 1; p[1] = 2; printf("%d %d\n",p[0],p[1]); } As to the code segment, I allocate 5 ints,first. And then I free the memory. When I printf p, why does p sill have a value same to the memory address allocated first? And I also can assign value to p[0] and p[1]. Does this mean free() do nothing? Once I allocate memory, I can use later though I have freed it.

    Read the article

  • Right recursive grammar or left recursive?

    - by user2485710
    I have little to no knowledge of what I'm about to ask, so I would like a suggestion based on the level of skills required to implemented a parser for the given grammar ( since I'm a beginner in this kind of formal approach to parsers and languages ). Just by going back of a couple of years, this situation reminds me a little of Pascal grammar vs C/C++ grammar, this left vs right stuff. But I'm not going to do any of that, my purpose is to implement a simple parser for a markup language for documents like Markdown. So considering that I'm starting with a markup language in mind, I want to keep things simple, which is the easiest one to handle between this 2 options and why . Another kind of grammar could be an easier option for me ? If yes which one do you suggest ?

    Read the article

  • How to transform a production to LL(1) grammar for a list separated by a semicolon?

    - by Subb
    Hi, I'm reading this introductory book on parsing (which is pretty good btw) and one of the exercice is to "build a parser for your favorite language." Since I don't want to die today, I thought I could do a parser for something relatively simple, ie a simplified CSS. Note: This book teach you how to right a LL(1) parser using the recursive-descent algorithm. So, as a sub-exercice, I am building the grammar from what I know of CSS. But I'm stuck on a production that I can't transform in LL(1) : //EBNF block = "{", declaration, {";", declaration}, [";"], "}" //BNF <block> =:: "{" <declaration> "}" <declaration> =:: <single-declaration> <opt-end> | <single-declaration> ";" <declaration> <opt-end> =:: "" | ";" This describe a CSS block. Valid block can have the form : { property : value } { property : value; } { property : value; property : value } { property : value; property : value; } ... The problem is with the optional ";" at the end, because it overlap with the starting character of {";", declaration}, so when my parser meet a semicolon in this context, it doesn't know what to do. The book talk about this problem, but in its example, the semicolon is obligatory, so the rule can be modified like this : block = "{", declaration, ";", {declaration, ";"}, "}" So, Is it possible to achieve what I'm trying to do using a LL(1) parser?

    Read the article

  • Any free WPF themes?

    - by TimothyP
    Duplicate: Where can I find free WPF controls and control templates? I'm not a designer, so I'm looking for some free WPF themes. Where can I find some good WPF themes?

    Read the article

  • How can I free memory on linux

    - by ogzylz
    When I use top to see memory usage, I see that I have 65gb ram but only 1.3gb of it free. When I ran my program It gives memory insufficiency error. Although no other program is using the remaining 63.7gb ram it is hold. how can I get free the unused ram?

    Read the article

  • Hudson Free Temp Space location

    - by Kevin
    Hi I have just installed Hudson on a Weblogic server and I am having issues with the nodes going off line due to the Free Temp Space falling below the 1gig threshold. Now I have checked my /tmp folder (thinking Hudson uses that) but it is sitting at 10gigs free. Would anybody be able to point me to the folder Hudson uses? Also I am using a SunOS box. Thanks,

    Read the article

  • List of free hosted domains (phishing prevention)

    - by nigative
    Does anyone has a compiled list of free hosting domains? On the website, when user clicks on external link I want them to be redirected to my page that will check if that external link is on free hosting or not. If it is, I want to warn the user, but right now I can't find a list of such domains. Any help?

    Read the article

  • Free server solution for strict content photos with geotags

    - by Max Gontar
    Hi! I would like to create some kind of open free "group" posting of photos with geotags First I thought about Panoramio, but seems there is no API for photos upload. By now I can see only two ways: Flickr - there are groups but you have to approve group membership anyway, or use tags for grouping which is bad for maintenance Custom server solution which will cost efforts and hosting Can you suggest other free photo services with geotags functionality, or opensource solutions? Thank you!

    Read the article

  • How to free static member variable in C++?

    - by user299831
    Can anybody explain how to free memory of a static member Variable? In my understanding it can only be freed if all the instances of the class are destroyed. I am a little bit helpless at this point... Some Code to explain it: class ball { private: static SDL_Surface *ball_image; }; //FIXME: how to free static Variable? SDL_Surface* ball::ball_image = SDL_LoadBMP("ball.bmp");

    Read the article

  • Partial template specialization of free functions - best practices

    - by Poita_
    As most C++ programmers should know, partial template specialization of free functions is disallowed. For example, the following is illegal C++: template <class T, int N> T mul(const T& x) { return x * N; } template <class T> T mul<T, 0>(const T& x) { return T(0); } // error: function template partial specialization ‘mul<T, 0>’ is not allowed However, partial template specialization of classes/structs is allowed, and can be exploited to mimic the functionality of partial template specialization of free functions. For example, the target objective in the last example can be achieved by using: template <class T, int N> struct mul_impl { static T fun(const T& x) { return x * N; } }; template <class T> struct mul_impl<T, 0> { static T fun(const T& x) { return T(0); } }; template <class T, int N> T mul(const T& x) { return mul_impl<T, N>::fun(x); } It's more bulky and less concise, but it gets the job done -- and as far as users of mul are concerned, they get the desired partial specialization. My questions is: when writing templated free functions (that are intended to be used by others), should you automatically delegate the implementation to a static method function of a class, so that users of your library may implement partial specializations at will, or do you just write the templated function the normal way, and live with the fact that people won't be able to specialize them?

    Read the article

  • glibc detected ./.a.out: free(): invalid pointer

    - by ExtremeBlue
    typedef struct _PERSON { size_t age; unsigned char* name; }PERSON; int init(PERSON** person) { (* person) = (PERSON *) malloc(sizeof(struct _PERSON)); (* person)->age = 1; (* person)->name = (unsigned char *) malloc(sizeof(4)); (* person)->name = "NAME"; return 0; } void close(PERSON** person) { (* person)->age = 0; if((* person)->name != NULL) { free((* person)->name); } if((* person) != NULL) { free((* person)); } } int main(int argc, char* argv[]) { PERSON* p; init(&p); printf("%d\t%s\n", (int) p->age, p->name); close(&p); return 0; } 1 NAME *** glibc detected *** ./a.out: free(): invalid pointer: 0x000000000040079c *** ======= Backtrace: ========= /lib/libc.so.6(+0x774b6)[0x7fa9027054b6] /lib/libc.so.6(cfree+0x73)[0x7fa90270bc83] ./a.out(close+0x3d)[0x400651] ./a.out[0x40069f] /lib/libc.so.6(__libc_start_main+0xfe)[0x7fa9026acd8e] ./a.out[0x4004f9] ... 7fa8fc000000-7fa8fc021000 rw-p 00000000 00:00 0 7fa8fc021000-7fa900000000 ---p 00000000 00:00 0 7fa902478000-7fa90248d000 r-xp 00000000 08:12 23068732 /lib/libgcc_s.so.1 7fa90248d000-7fa90268c000 ---p 00015000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268c000-7fa90268d000 r--p 00014000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268d000-7fa90268e000 rw-p 00015000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268e000-7fa902808000 r-xp 00000000 08:12 23068970 /lib/libc-2.12.1.so 7fa902808000-7fa902a07000 ---p 0017a000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a07000-7fa902a0b000 r--p 00179000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a0b000-7fa902a0c000 rw-p 0017d000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a0c000-7fa902a11000 rw-p 00000000 00:00 0 7fa902a11000-7fa902a31000 r-xp 00000000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c25000-7fa902c28000 rw-p 00000000 00:00 0 7fa902c2e000-7fa902c31000 rw-p 00000000 00:00 0 7fa902c31000-7fa902c32000 r--p 00020000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c32000-7fa902c33000 rw-p 00021000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c33000-7fa902c34000 rw-p 00000000 00:00 0 7fff442d5000-7fff442f6000 rw-p 00000000 00:00 0 [stack] 7fff44308000-7fff44309000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted

    Read the article

  • What is the difference between an object's scope and it's context in javascript?

    - by DKinzer
    In the vernacular, scope and context have a lot in common. Which is why I get confused when I read references to both, such as in the quote below from an article on closures: Scope refers to where variables and functions are accessible, and in what context it is being executed. (@robertnyman) As far as I can tell, context is just a reference to an object. Can someone please explain what exactly is context, as used, for instance, in the jQuery syntax, $(selector, context). And is an object's scope the same at it's context?

    Read the article

  • Add a right click context menu in certain WIndows folders that will open a web browser URL?

    - by jasondavis
    In a Windows Explorer window where you browse files in Windows 7, I would like to add a new context menu that will allow me to open a file on my local Dev Server. So it would have to open a browser like Google Crome and the URL would have to be the file path but slightly different removing part of it and prepending my localhost URL. For example if the file I am right clicking on, the path for that file might be... E:\Server\htdocs\labs\php\testProject\test.php I would need a button to click in the context menu Open in Browser and it would open my Web Browser with a URL like this... http://localhost/labs/php/testProject/test.php I would love to be able to do this, any ideas or help would greatly be appreciated! To go one step further, would to be able to somehow make the context menu item only show up on File that are under this folder.... ``E:\Server\htdocs` but this is far less important.

    Read the article

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