Search Results

Search found 27946 results on 1118 pages for 'output buffer empty'.

Page 154/1118 | < Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >

  • Is the C++ compiler optimizer allowed to break my destructor ability to be called multiple times?

    - by sharptooth
    We once had an interview with a very experienced C++ developer who couldn't answer the following question: is it necessary to call the base class destructor from the derived class destructor in C++? Obviously the answer is no, C++ will call the base class destructor automagically anyway. But what if we attempt to do the call? As I see it the result will depend on whether the base class destructor can be called twice without invoking erroneous behavior. For example in this case: class BaseSafe { public: ~BaseSafe() { } private: int data; }; class DerivedSafe { public: ~DerivedSafe() { BaseSafe::~BaseSafe(); } }; everything will be fine - the BaseSafe destructor can be called twice safely and the program will run allright. But in this case: class BaseUnsafe { public: BaseUnsafe() { buffer = new char[100]; } ~BaseUnsafe () { delete[] buffer; } private: char* buffer; }; class DerivedUnsafe { public: ~DerivedUnsafe () { BaseUnsafe::~BaseUnsafe(); } }; the explicic call will run fine, but then the implicit (automagic) call to the destructor will trigger double-delete and undefined behavior. Looks like it is easy to avoid the UB in the second case. Just set buffer to null pointer after delete[]. But will this help? I mean the destructor is expected to only be run once on a fully constructed object, so the optimizer could decide that setting buffer to null pointer makes no sense and eliminate that code exposing the program to double-delete. Is the compiler allowed to do that?

    Read the article

  • How to execute ant using java and captured the output?

    - by Iso
    Hi, I have an ant build file that contains JUnit test suite that I would like to execute. Currently I just right click and run the build file from Eclipse. I want to write a java code that can execute the ant build file automatically. So I just run the code and ant will be executed. Second is I want to capture the test result. Currently the result is based on JUnit HTML report. I want to make my own simple test report. I read there is JUnitResultFormatter but I can't find the instructional step by step how to use it. Can anyone point me the reference? Thanks in advance.

    Read the article

  • Preallocating memory with C++ in realtime environment

    - by Elazar Leibovich
    I'm having a function which gets an input buffer of n bytes, and needs an auxillary buffer of n bytes in order to process the given input buffer. (I know vector is allocating memory at runtime, let's say that I'm using a vector which uses static preallocated memory. Imagine this is NOT an STL vector.) The usual approach is void processData(vector<T> &vec) { vector<T> &aux = new vector<T>(vec.size()); //dynamically allocate memory // process data } //usage: processData(v) Since I'm working in a real time environment, I wish to preallocate all the memory I'll ever need in advance. The buffer is allocated only once at startup. I want that whenever I'm allocating a vector, I'll automatically allocate auxillary buffer for my processData function. I can do something similar with a template function static void _processData(vector<T> &vec,vector<T> &aux) { // process data } template<size_t sz> void processData(vector<T> &vec) { static aux_buffer[sz]; vector aux(vec.size(),aux_buffer); // use aux_buffer for the vector _processData(vec,aux); } // usage: processData<V_MAX_SIZE>(v); However working alot with templates is not much fun (now let's recompile everything since I changed a comment!), and it forces me to do some bookkeeping whenever I use this function. Are there any nicer designs around this problem?

    Read the article

  • show output of file on client side using jquery + javascript .

    - by tazimk
    Hi, Written some code in my view function : This code reads a file from server . stores it in a list .passes to client def showfiledata(request): f = open("/home/tazim/webexample/test.txt") list = f.readlines() return_dict = {'list':list} json = simplejson.dumps(list) return HttpResponse(json,mimetype="application/json") On, client side the $.ajax callback function receives this list of lines. Now, My Question is . I have to display these lines in a textarea. But these lines should not be displayed at once . Each line should be appended in textarea with some delay. (Use of setInterval is required as per my knowledge) . Also I am using jquery in my templates. The server used is Django . Please provide some solution as in some sample code will be quite helpful .

    Read the article

  • wxPython - How can I display a html formatted string in wx.RichTextCtrl

    - by wxpydon
    Hello, I'm trying to display some string (html formatted) in a Richtext Ctrl. In my code I tried to use it this way (self.txtmain is the RichTextCtrl): out = StringIO() htmlhandler = rt.RichTextHTMLHandler() buffer = self.txtmain.GetBuffer() buffer.AddHandler(htmlhandler) out.write(string) out.seek(0) htmlhandler.LoadStream(buffer, out) self.txtmain.Refresh() No errors are issued, but the RichTextCtrl windows is not updated. What am I missing here?

    Read the article

  • Inconsistent Behavior From Declared DLL Function

    - by Steven
    Why might my GetRawData declared function return a correct value when called from my VB.NET application, but return zero when called from my ASP.NET page? The code is exactly the same except for class type difference (Form / Page) and calling event handler (Form1_Load, Page_Load). Note: In the actual code, #DLL# and #RAWDATAFILE# are both absolute filenames to my DLL and raw data file respectively. Note: The DLL file was not created by Visual Studio. Form1.vb Public Class Form1 Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length) Default.aspx.vb Partial Public Class _Default Inherits System.Web.UI.Page Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Protected Sub Page_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length)

    Read the article

  • Why does this log output show the same answer in each iteration?

    - by Will Hancock
    OK, I was reading an article on optimising JS for Googles V8 engine, when i saw this code example... I nearly skimmed over it, but then I saw this; |=; a[0] |= b; a = new Array(); a[0] = 0; for (var b = 0; b < 10; b++) { console.log(a, b) a[0] |= b; // Much better! 2x faster. } a[0] |= b; So I ran it, in my console, with a console.log in the loop and resulted in 15; [15] 0 [15] 1 [15] 2 [15] 3 [15] 4 [15] 5 [15] 6 [15] 7 [15] 8 [15] 9 WHAT?!?! Where the hell does it get 15 from, on every iteration?!?!?! I've been a web dev for 7 years, and this has stumped me and a fellow colleague. Can somebody talk me through this code? Cheers.

    Read the article

  • In ASP.NET, is it possible to output cache by host name? ie varybyhost or varbyhostheader?

    - by Pure.Krome
    Hi folks, I've got a website that has a number of host headers. Depending on the host header, the results are different - both visually (theme'd) and data. So lets imagine i have a website called 'Foo' - that returns search results (original, eh?). Now, the same code runs both sites. It is physically the same server/website (using Host Headers) :- www.foo.com www.foo.com.au Now, if i goto '.com', the site is theme'd in blue. if i goto the '.com.au' site, it's theme'd in red. And the data is different for the same search result, based on the host name (ie. us results for .com, au results for .com.au) SO .. if i wish to use OutputCaching .. can this be handled / differ by the host name? I don't want to have the first person goto the .com site .. grab the results ... and the a second person goto my .com.au .. same search data .. and get the theme and results for the .com site. Possible?

    Read the article

  • Make function declarations based on function definitions

    - by Clinton Blackmore
    I've written a .cpp file with a number of functions in it, and now need to declare them in the header file. It occurred to me that I could grep the file for the class name, and get the declarations that way, and it would've worked well enough, too, had the complete function declaration before the definition -- return code, name, and parameters (but not function body) -- been on one line. It seems to me that this is something that would be generally useful, and must've been solved a number of times. I am happy to edit the output and not worried about edge cases; anything that gives me results that are right 95% of the time would be great. So, if, for example, my .cpp file had: i2cstatus_t NXTI2CDevice::writeRegisters( uint8_t start_register, // start of the register range uint8_t bytes_to_write, // number of bytes to write uint8_t* buffer = 0) // optional user-supplied buffer { ... } and a number of other similar functions, getting this back: i2cstatus_t NXTI2CDevice::writeRegisters( uint8_t start_register, // start of the register range uint8_t bytes_to_write, // number of bytes to write uint8_t* buffer = 0) for inclusion in the header file, after a little editing, would be fine. Getting this back: i2cstatus_t writeRegisters( uint8_t start_register, uint8_t bytes_to_write, uint8_t* buffer); or this: i2cstatus_t writeRegisters(uint8_t start_register, uint8_t bytes_to_write, uint8_t* buffer); would be even better.

    Read the article

  • Creating android app Database with big amount of data

    - by Thomas
    Hi all, The database of my application need to be filled with a lot of data, so during onCreate(), it's not only some create table sql instructions, there is a lot of inserts. The solution I chose is to store all this instructions in a sql file located in res/raw and which is loaded with Resources.openRawResource(id). It works well but I face to encoding issue, I have some accentuated caharacters in the sql file which appears bad in my application. This my code to do this : public String getFileContent(Resources resources, int rawId) throws IOException { InputStream is = resources.openRawResource(rawId); int size = is.available(); // Read the entire asset into a local byte buffer. byte[] buffer = new byte[size]; is.read(buffer); is.close(); // Convert the buffer into a string. return new String(buffer); } public void onCreate(SQLiteDatabase db) { try { // get file content String sqlCode = getFileContent(mCtx.getResources(), R.raw.db_create); // execute code for (String sqlStatements : sqlCode.split(";")) { db.execSQL(sqlStatements); } Log.v("Creating database done."); } catch (IOException e) { // Should never happen! Log.e("Error reading sql file " + e.getMessage(), e); throw new RuntimeException(e); } catch (SQLException e) { Log.e("Error executing sql code " + e.getMessage(), e); throw new RuntimeException(e); } The solution I found to avoid this is to load the sql instructions from a huge static final string instead of a file, and all accentutated characters appears well. But Isn't there a more elegant way to load sql instructions than a big static final String attribute with all sql instructions ? Thanks in advance Thomas

    Read the article

  • Alert and if changes behaviour dom copying

    - by lowkey
    Hi guys! Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools is used for DOM navigation Description: HTML: 1 iframe called "buffer" 1 div called "display" JAVASCRIPT: (short: copy iframe content into a div on the page) 1) onLoad on iframe triggers handler(), a counter makes sure it only run once (this is because otherwise firefox will go into feedback loop. What i think happens: iframe on load handler() copyBuffer change src of iframe , and firefox takes that as an onload again) 2) copybuffer() is called, it sets src of iframe then copies iframe content into div, then erases iframe content THE CODE: count=0; function handler(){ if (count==0){ copyBuffer(); count++; } } function copyBuffer(){ $('buffer').set('src','http://www.somelink.com/'); if (window.frames['buffer'] && $('display') ) { $('display').innerHTML = window.frames['buffer'].document.body.innerHTML; window.frames['buffer'].document.body.innerHTML=""; } } problems: QUESTION 1) nothing happens, the content is not loaded into the div. But if i either: A) remove the counter and let the script run in a feedback loop: the content is suddenly copied into the div, but off course there is a feedback loop going on, you can see it keeps loading in the status bar. OR B) insert an alert in the copyBuffer function. The content is copied, without the feedback loop. why does this happen? QUESTION 2) The If wrapped around the copying code i got from a source on the internet. I am not sure what it does? If i remove it the code does not work in: Safari and Chrome. Many thanks in advance!

    Read the article

  • Why is C++ fwrite() producing larger output in release?

    - by waffleShirt
    I recently wrote an implementation of the Canonical Huffman compression algorithm. I have a 500kb test file that can be compressed to about 250kb when running the debug and release builds from within Visual Studio 2008. However when I run the release build straight from the executeable the test file only compresses to about 330kb. I am assuming that something is going wrong when the file is written using fwrite(). I have tested the program and confirmed that uncompressing the files always produces the correct uncompressed file. Does anyone know why this could possibly be? How could the same executeable file be producing different sized outputs based on where it is launched from?

    Read the article

  • Image Handler for Sharepoint Not Working

    - by Peter
    My ImageHandler.ashx is not working when the webpart is calling it. any ideas on what is the correct way on calling or adding a handler in sharepoint? Thanks in advance Here My ImageHandler.ashx code byte[] buffer = (byte[])image.ImageData; context.Response.ContentType = "image/jpeg"; context.Response.OutputStream.Write(buffer, 0, buffer.Length); In my webpart imgcontrol.ImageUrl = "ImageHandler.aspx?id=1";

    Read the article

  • Shortest command to calculate the sum of a column of output on Unix?

    - by Andrew
    I'm sure there is a quick and easy way to calculate the sum of a column of values on Unix systems (using something like awk or xargs perhaps), but writing a shell script to parse the rows line by line is the only thing that comes to mind at the moment. For example, what's the simplest way to modify the command below to compute and display the total for the SEGSZ column (70300)? ipcs -mb | head -6 IPC status from /dev/kmem as of Mon Nov 17 08:58:17 2008 T ID KEY MODE OWNER GROUP SEGSZ Shared Memory: m 0 0x411c322e --rw-rw-rw- root root 348 m 1 0x4e0c0002 --rw-rw-rw- root root 61760 m 2 0x412013f5 --rw-rw-rw- root root 8192

    Read the article

  • MySQL error code:1329 in function

    - by Sharad Sharma
    DELIMITER // CREATE DEFINER=`root`@`localhost` FUNCTION `formatMovieNames`(lID int) RETURNS varchar(1000) CHARSET latin1 BEGIN DECLARE output varchar(1000); DECLARE done INT DEFAULT 0; declare a varchar(200); declare cur1 cursor for select fileName from swlp4_movie where movieID in (select movieID from lesson_movie_map where lessonID = lID order by lm_map_id); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; open cur1; read_loop: loop fetch cur1 into a; if done = 1 then leave read_loop; end if; set output = concat(output, 'movie:[',a,']<br/>'); set output = substr(output, 0, length(@output)-5); end loop; close cur1; RETURN output; END// I have create this function and when I run it I do not get any output (select fileName from swlp4_movie where movieID in (select movieID from lesson_movie_map where lessonID = 24 order by lm_map_id)); brings correct result I am trying to get result as movie:['movieName']< br / movie:['movieName1'] and so on (had to change br tag, cause it was adding a line break) cant't figure out what I am doing wrong

    Read the article

  • get the current time in C

    - by Antrromet
    I want to get the current time of my system. For that i'm using the following code in C. time_t now; struct tm *mytime = localtime(&now); if ( strftime(buffer, sizeof buffer, "%X", mytime) ) { printf("time1 = \"%s\"\n", buffer); } But the problem of this code is that its giving some random time.Also the random time is different all the time.I want the current time of my system. Can anyone please tell me how to solve this issue?

    Read the article

  • C string program

    - by mrblippy
    Hi, i have been given a task to do ar school that must read three strings in, store the third string in dynamically allocated memory and print out the last 4 letters of the first word alphabetically. Here is the program i have so far but the strings are all stored in different variables, making them hard to sort. if anyone could give me a hand and help me finish this program i would be very grateful. thanks #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char word1[101]; char word2[101]; char* word3; char buffer[101]; scanf("%s", word1); scanf("%s", word2); scanf("%s", buffer); word3 = (char *) malloc(strlen(buffer)+1); strcpy(word3, buffer); return 0; }

    Read the article

  • Is it possible to determine whose code (according to `git blame`) was affected by each hunk output by `git diff`?

    - by Ben
    I have a large cross-cutting commit that I would like to split up according to the authors whose code was affected, both to increase the reviewers' familiarity with the code they're reviewing, and to divide the review burden equitably. I realize that the blame may be mixed within a given hunk, in which case it would be nice to either collect multiple reviewers or just choose the most "blameworthy" one (breaking ties arbitrarily is fine).

    Read the article

  • Allocating memory in char * struct

    - by mrblippy
    hi, im trying to read in a word from a user, then dynamically allocate memory for the word and store it in a struct array that contains a char *. i keep getting a implicit declaration of function âstrlenâ so i know im going wrong somewhere. struct class { char class_code[7]; char *name; }; char buffer[101]; struct unit units[1000]; scanf("%s", buffer); units[0].name = (char *) malloc(strlen(buffer)+1); strcpy(units[0].name, buffer);

    Read the article

< Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >