[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] XaAES crash errors



On Sat, Dec 5, 2009 at 11:38 PM, Kåre Andersen <kareandersen@gmail.com> wrote:
> On Sat, Dec 5, 2009 at 12:21 PM, Paul Wratt <paul.wratt@gmail.com> wrote:
>
>> Also, can anyone tell me how to initialize a CHAR var when you dont
>> know what the max length will. I have had no success in either a net
>> search, or looking through the code (for other uses of it)
>
> A char is exactly one byte. In C, strings are made with arrays of type
> char - that means what you are looking for is not char, but pointer to
> char!
>
> Dynamically sized strings can be made with malloc. There is also a
> bunch of functions with names starting with str, like strcpy, which
> means there is no need to reinvent a bunch of wheels for each piece of
> software written. Please make yourself familiar with pointers and the
> standard libraries. Vast amounts of documentation on this on the
> web...
>
> One suggestion for reading is
> http://publications.gbdirect.co.uk/c_book/chapter5/character_handling.html
> - although knowing pointers and arrays first is probably a good idea.
> Also, any set of *nix manpages will be a great asset (esp. for the
> string functions).
>
> Best of luck :)
>
> /Kåre
>
Thanks dude

I am aware of the "str" functions, having seen them used in other
XaAES code, they are pretty much like php, which is handy to know. I
tried grabbing a C cheat sheet, but they are somewhat limited in what
they contain. I saw the kernel compile a "strstr" and "strrstr"
object, which is how php does it (when not using alias's for them).

I know about pointers, for what I am doing, if its not "char
*temp_file_name;" it wont compile. The problem is that it shows a
warning about that var "possibly uninitialized" (I think because it is
"hidden" in an if block). I am using this particular var name in other
functions, so I guess it would be OK to declare it as "static char
*temp_file_name[256];" outside of any functions (its a file name with
path info).

Its just I dont like "limiting" strings where path and file name info
is concerned, as you never know when it will get exceeded..

question..

In XaAES, during the loading of the config file, each line is passed
straight to function as "char *line". most function then pass that
line on to be broken down in some way, they it as "&line" (eg s =
get_string(&line) ). line is then referenced as "char **line".

The question: how do I pass "char *line" through to an intermediate
function that can then pass "&line" correctly. Would passing "*line"
be enough..

Truely, the biggest problem I am having, is knowing what terms to use
when I search for things. I will find a function reference at some
point, and searching for function names is not a problem if you know
what they are.. The only way I can justify this thread is because its
is directly to XaAES

Paul