Programming :: Does Declaring Variable Inside A Function Give An Extra Overhead On An Application
May 14, 2011
Does declaring variable inside a function give an extra overhead on an application? Would it be better to declare the variable globally and just reuse it? Example
Code:
#include <blah>
char mybuffer[2048];
int main()
[code]....
The only difference is the declaration of my variable. Since myfunction() will be called many times will it add an additional overhead if it will create mybuffer[2048] over and over?
I was wondering if possible in bash for a variable to take the value of a function, I mean the function returns a value and a variable will take it. example:
I am very new to shell script, and my requirement is --
1. open the apache access log, use "cut" and "grep" to find the numbers. 2.put the result in a file 3.then compare the same result with day before result 4. send the result via e-mail.
I have a class in which a have declared a private variable "time". In one of the public functions, I am returning the value of "time" (either directly by using "return time;" or by something similar to "x=time; return x;" but I keep getting a compiling error saying that "time" is not declared in this scope.
In the above example, the functions take no input arguments. Can they take a different number of arguments, for example, function_a(int), function_c(int, int), function_e(int, char, int)? How can I do that?
I have a PHP script which will show info from 5 lines in a MySQL database, with a "next" button to show the next 5 lines and so on. Initially it'll get called with a ?page=1 in the args in the URL, and then onward I want the "next" button to link to the same script , but with a ?page=2 in the args. First of all, how can I access the "page" variable inside the script to see what args it's been given? (sorry, extremely newbie question here )
And secondly, what will the code for the "next" button look like? If the script is called "seenames.php", I want this: print "A HREF="...cgi/seenames.php?page=$page+1">Next</A> , if you get my meaning. But what will the quoting for the above line be? I'm sure I've got it wrong.
We have a STM32F103ZET6 microcontroller.It has an ARM cortex-M3 core.We use keil as compiler.We have both an external and internal SRAM.Now I want to declare variables in either of the RAM as I wish.For example some time critical section variables in internal and others in external.How to do this.?
I've run in to one problem which makes me go back to Windows 7,and that's not being able to change my extra mouse buttons to function as volume up and down. I watch a lot of movies and series on my PC, and I use my wireless mouse to control volume and to pause and play. The last 2 are no problem, but I can't seem to find an option to change the function of the extra mouse buttons.I've looked all over the net, and read various forums, they don't have a clear answer or even an idea how to accomplish this. So I turned to this forum, which I should have done in the first place.
I have around 150+ folders in one directory. All contains some pdf files. Now i want to give some prefix no. to folder only not the files inside. How can i give the prefix to all my folders?Eg : Suppose i want no. 8562 then i want it like as follows
OLD FOLDER NEW FOLDER ABC/ 8562-ABC/ AABC/ 8562-AABC/
I have trouble with using an alias inside aash function. I would like to ssh into multiple machines by executing:ssh machine To achieve this, I put something like the following into my ~/.bashrc:
I have a fresh desktop install ubuntu 10.04 which then I added the fvwm-crystal package (and dependencies). I logout of gnome, and into fvwm. When I do so, I lose my wireless connection that was started when I was in gnome. Is there a way to get a wireless manager to function inside fvwm (if I add it to the auto-start in my fvwm2rc?). What app can I use? I tried and failed miserably using the command line iwconifg/iwlist tools.
I need to shift the positional parameters of a script inside a function, but any call to "shift 1" inside a function shifts only the parameters of that function. Is there some way of accomplishing that? I tried another approach using an alias. The problem is that I have to take the result of the alias. So I call in my script:
Code:
var=$(shiftalias)
At first time, it works correctly, but after that it does not shift the parameters anymore.
Problem: I need a method to maintain the $i variable. In fact, actually, this variable get lost when executed. I think that an escape can preserve this variable and permit its execution inside the function, but I've no idea about.
The first call to "somefunction" works as expected. The function prints "endfunction" and a process in background sleeps 30 seconds. In the second call I thought it should work in the same way, but the script sleeps 30 seconds before it prints "endfunction".Does someone know the reason of this behavior? Is there another way to do a command substitution of a function that has a background process without have to waiting for that process?
i need to count the number of files and put the output into a variable. i used wc -l filename but i couldnt find an option to put the output to variable. example if the number o line is 5, i need the output of echo $x is 5.
I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.
when i install wubi and ubuntu inside windows 7 it doesn't show my other drive in ubuntu that i have in windows 7 how do i activate my extra drive inside ubuntu also when i went in disk utility inside ubuntu if said mounted at host but i want to show it inside ubuntu and the version of ubuntu that i have 11.04
I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.
For example:
Code:
Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).
my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.
i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't
How can I give an application group permissions?There is a bug in the latest version of Ubuntu's Dovecot, where it is not apart of mail group, so it does not have write permission to the /var/mail directory by default. So I have to give it mail group permissions.
i want to know that which application in linux will give me access to the router like in windows we use hyper terminal or i have to install a particular package
I have a web application which calls scripts on the linux box it's deployed on. Currently, there are some file permission issues which prevent the scripts from running properly. How can I give my web application the needed permissions? I thought of creating a user 'group' , assigning my web app to that group, and changing the ownership of the script files to the new group. Unfortunately, I'm having trouble with the following: What user id does my web app have? If my web app does not have an user id,