unsigned char *Buf;
Buf = new unsigned char[100];
unsigned long sz = 100 * sizeof(unsigned char);
Read(Buf,&sz);
Occassional app crash at Read(Buf,&sz) call.
maybe empty data, null Buf??.
what's best way?.
Lib:
Read ( unsigned char * Buf ,
unsigned long * BufSize );
--
Sent by nysfp from hotmail subpart from com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new 4 2353
"ny***@hotmail.com" <u5********@spawnkill.ip-mobilphone.net> wrote in
message news:l.*********************@[63.127.215.130]... unsigned char *Buf; Buf = new unsigned char[100]; unsigned long sz = 100 * sizeof(unsigned char); Read(Buf,&sz); Occassional app crash at Read(Buf,&sz) call. maybe empty data, null Buf??.
Maybe, yes. Maybe the error lies elsewhere. The point is that the error
obviously occurs inside 'Read' and you have not shown anything about that
function. If it is function of a third-party library, you should try asking
the developers or a forum dedicated to this library. Otherwise, please show
the relevant code of that function.
hth
--
jb
(replace y with x if you want to reply by e-mail) ny***@hotmail.com wrote: unsigned char *Buf; Buf = new unsigned char[100]; unsigned long sz = 100 * sizeof(unsigned char);
sizeof(unsigned char) is a fancy way of writing 1.
Read(Buf,&sz); Occassional app crash at Read(Buf,&sz) call. maybe empty data, null Buf??. what's best way?.
Lib: Read ( unsigned char * Buf , unsigned long * BufSize );
Why is this a pointer? Are you sure the library is not modifying your
size, causing it to be incorrect when you call this function later?
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
"ny***@hotmail.com" wrote: unsigned char *Buf; Buf = new unsigned char[100]; unsigned long sz = 100 * sizeof(unsigned char); Read(Buf,&sz); Occassional app crash at Read(Buf,&sz) call. maybe empty data, null Buf??. what's best way?.
Lib: Read ( unsigned char * Buf , unsigned long * BufSize );
I think you are using your library the wrong way.
An interface like the above is usually feed like this:
unsigned char *Buf;
unsigned long BuffSize;
Buf = new unsigned char [ 100 ];
BuffSize = 100;
Read( Buf, &BuffSize );
and read will modify BuffSize to the number of unsigned chars
it put into Buf. But it wants to know in the beginning how large
that buffer actually is, in order to avoid what you have seen:
accessing the array out of bounds and thus end up in an access
violation.
Consult your documentation, if that's what Read does.
--
Karl Heinz Buchegger kb******@gascad.at
Karl Heinz Buchegger wrote: "ny***@hotmail.com" wrote: unsigned char *Buf; Buf = new unsigned char[100]; unsigned long sz = 100 * sizeof(unsigned char); Read(Buf,&sz); Occassional app crash at Read(Buf,&sz) call. maybe empty data, null Buf??. what's best way?.
Lib: Read ( unsigned char * Buf , unsigned long * BufSize );
I think you are using your library the wrong way. An interface like the above is usually feed like this:
unsigned char *Buf; unsigned long BuffSize;
Buf = new unsigned char [ 100 ]; BuffSize = 100;
Read( Buf, &BuffSize );
Ooops. Sorry. At reread I notices that thats exactly
what you are doing.
--
Karl Heinz Buchegger kb******@gascad.at This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dmitry D |
last post by:
Hi,
I'm new to C++ (started learning in the beginning of this summer), and I
have the following question (sorry if it sounds stupid):
In many code samples and source files, I see NULL expression...
|
by: DevarajA |
last post by:
I've read that 0 is the 'null pointer constant', and assigning it to a
pointer makes it a 'null pointer'. Is that true? And is the opposite
true? (assigning a null pointer to an int sets the int to...
|
by: junky_fellow |
last post by:
Can 0x0 be a valid virtual address in the address space
of an application ?
If it is valid, then the location pointed by a NULL pointer
is also valid and application should not receive "SIGSEGV"...
|
by: Jason Curl |
last post by:
I've been reading this newsgroup for some time and now I am thoroughly
confused over what NULL means.
I've read a NULL pointer is zero (or zero typecast as a void pointer),
others say it's...
|
by: Mikhail Teterin |
last post by:
Hello!
Consider the following simple accessor function:
typedef struct {
int i;
char name;
} MY_TYPE;
const char *
|
by: Alexei A. Frounze |
last post by:
Seems like, to make sure that a pointer doesn't point to an object/function,
NULL (or simply 0) is good enough for both kind of pointers, data pointers
and function pointers as per 6.3.2.3:
3 An...
|
by: fieldfallow |
last post by:
Hello all,
Before stating my question, I should mention that I'm fairly new to C.
Now, I attempted a small demo that prints out the values of C's numeric
types, both uninitialised and after...
|
by: khan |
last post by:
Hi,
I read that pointer representation can non-zero bit pattern, machine
specific.Compiler when comes accross value '0' in pointer context,
converts it to machine specific null pointer...
|
by: muktipada |
last post by:
Hello,
As a C++ developer which one we should use for pointer assignment,
NULL or 0.
typedef DummyC DummyClass*; // in some header file.
DummyC obj = NULL;
if (obj == NULL) {
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |